Search Results

Search found 70 results on 3 pages for 'morten pedersen'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • ISA Web Farm and WCF service hosted in a Windows Service with basicHttpBinding

    - by Ryan Pedersen
    I have created a WCF service that needs to be hosted in a Window Service because it is participating in a P2P mesh (NetPeerTcpBinding). When I tried to host the WCF Service with NetPeerTcpBinding endpoints in the IIS Service container the service wouldn't run because it turns out that the P2P binding doesn't work in IIS. I have exposed a HTTP endpoint from the WCF service hosted in a Windows Service container and I want to know if there is a way to create an ISA Web Farm that will route traffic to http endpoints on two machines each running the same WCF service in a Windows Service container.

    Read the article

  • Setting up RADIUS + LDAP for WPA2 on Ubuntu

    - by Morten Siebuhr
    I'm setting up a wireless network for ~150 users. In short, I'm looking for a guide to set RADIUS server to authenticate WPA2 against a LDAP. On Ubuntu. I got a working LDAP, but as it is not in production use, it can very easily be adapted to whatever changes this project may require. I've been looking at FreeRADIUS, but any RADIUS server will do. We got a separate physical network just for WiFi, so not too many worries about security on that front. Our AP's are HP's low end enterprise stuff - they seem to support whatever you can think of. All Ubuntu Server, baby! And the bad news: I now somebody less knowledgeable than me will eventually take over administration, so the setup has to be as "trivial" as possible. So far, our setup is based only on software from the Ubuntu repositories, with exception of our LDAP administration web application and a few small special scripts. So no "fetch package X, untar, ./configure"-things if avoidable. UPDATE 2009-08-18: While I found several useful resources, there is one serious obstacle: Ignoring EAP-Type/tls because we do not have OpenSSL support. Ignoring EAP-Type/ttls because we do not have OpenSSL support. Ignoring EAP-Type/peap because we do not have OpenSSL support. Basically the Ubuntu version of FreeRADIUS does not support SSL (bug 183840), which makes all the secure EAP-types useless. Bummer. But some useful documentation for anybody interested: http://vuksan.com/linux/dot1x/802-1x-LDAP.html http://tldp.org/HOWTO/html_single/8021X-HOWTO/#confradius UPDATE 2009-08-19: I ended up compiling my own FreeRADIUS package yesterday evening - there's a really good recipe at http://www.linuxinsight.com/building-debian-freeradius-package-with-eap-tls-ttls-peap-support.html (See the comments to the post for updated instructions). I got a certificate from http://CACert.org (you should probably get a "real" cert if possible) Then I followed the instructions at http://vuksan.com/linux/dot1x/802-1x-LDAP.html. This links to http://tldp.org/HOWTO/html_single/8021X-HOWTO/, which is a very worthwhile read if you want to know how WiFi security works. UPDATE 2009-08-27: After following the above guide, I've managed to get FreeRADIUS to talk to LDAP: I've created a test user in LDAP, with the password mr2Yx36M - this gives an LDAP entry roughly of: uid: testuser sambaLMPassword: CF3D6F8A92967E0FE72C57EF50F76A05 sambaNTPassword: DA44187ECA97B7C14A22F29F52BEBD90 userPassword: {SSHA}Z0SwaKO5tuGxgxtceRDjiDGFy6bRL6ja When using radtest, I can connect fine: > radtest testuser "mr2Yx36N" sbhr.dk 0 radius-private-password Sending Access-Request of id 215 to 130.225.235.6 port 1812 User-Name = "msiebuhr" User-Password = "mr2Yx36N" NAS-IP-Address = 127.0.1.1 NAS-Port = 0 rad_recv: Access-Accept packet from host 130.225.235.6 port 1812, id=215, length=20 > But when I try through the AP, it doesn't fly - while it does confirm that it figures out the NT and LM passwords: ... rlm_ldap: sambaNTPassword -> NT-Password == 0x4441343431383745434139374237433134413232463239463532424542443930 rlm_ldap: sambaLMPassword -> LM-Password == 0x4346334436463841393239363745304645373243353745463530463736413035 [ldap] looking for reply items in directory... WARNING: No "known good" password was found in LDAP. Are you sure that the user is configured correctly? [ldap] user testuser authorized to use remote access rlm_ldap: ldap_release_conn: Release Id: 0 ++[ldap] returns ok ++[expiration] returns noop ++[logintime] returns noop [pap] Normalizing NT-Password from hex encoding [pap] Normalizing LM-Password from hex encoding ... It is clear that the NT and LM passwords differ from the above, yet the message [ldap] user testuser authorized to use remote access - and the user is later rejected...

    Read the article

  • Outlook meetings and auto accept/reply

    - by Morten
    First, I'm not sure if this question should be here or superuser, but here it comes. Im trying to set up a room to auto accept meetings and so far its good but i was wondering if it's possible to change it to "do not send respond" when it accepts and sends some reply when it's the same time as another existing meeting, so it declined. And a little extra question: is it possible to chance that auto reply it sends, since it's in English, and I would like to chance it to Danish and some text I choose myself?

    Read the article

  • Enable 2-way databinding on nested listview

    - by Lars Pedersen
    I have a ASP.NET FormView, that - via an ObjectDataSource - is bound to my EventOrder-object: [Serializable] public class EventOrder { [Serializable] public class OrderTicket { public int Qty { get; set; } public int Id { get { return this.Ticket.Id; } } public Ticket Ticket { get; set; } public double TicketPrice { get; set; } } [Serializable] public class OrderExtra { public int Qty { get; set; } public int Id { get { return this.Extra.Id; } } public Extra Extra { get; set; } } public Event Event { get; set; } public List<OrderTicket> OrderTickets { get; set; } public List<OrderExtra> OrderExtras { get; set; } public UserProfile UserProfile { get; set; } public List<Fee> Fees { get; set; } public List<Discount> Discounts { get; set; } public EventOrder() { this.OrderExtras = new List<OrderExtra>(); this.OrderTickets = new List<OrderTicket>(); this.Fees = new List<Fee>(); this.Discounts = new List<Discount>(); } } In my FormView, I have a bindingexpression on an inner listview for my collection of OrderTickets: <asp:ListView Visible="false" runat="server" DataKeyNames="Id" ID="lvTickets" DataSource='<%# Bind("OrderTickets") %>'> <ItemTemplate> <asp:TextBox ID="TextBox5" Text='<%# Bind("Qty") %>' runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text='<%# Eval("Ticket.Title") %>'></asp:Label> <asp:Label ID="Label2" runat="server" Text='<%# Eval("TicketPrice") %>'></asp:Label><br /> </ItemTemplate> My problem is that the Qty-property isn't databound to the object when the parent container is updated. Is it possible to have this kind of parent-child relation with 2-way databinding? Can I force the child listview to update it's bound dataobject when I submit the form?

    Read the article

  • What off-the-shelf licensing system will meet my needs?

    - by Anders Pedersen
    I'm looking for an off-the-shelf license system for desktop software. After some research on the net -- and of course here on StackOverflow -- I haven't found one the suits our needs. I have a couple of must-have features and some would-be-nice features: Must have: Encrypted unlock key Possibility to automate the unlock key generation on my website User info in key so that I can show name and company in an about box and perhaps in reports Nice to have: License managing tools Online activation Nice upgrade possibilities to a version with concurrent license model and subscription model I have looked at Manco, but I find them difficult to work with and the documentation is minimal. Further, I couldn't get the name in the key. Also, the automatic generation of a key on my website has to be done with an application web service, but I would rather program against a DLL. Next I looked at xheo. It is easier to use and the documentation is better, but the price is substantially higher and here you can only get the user name in the license file that you then have to provide together with the unlock key. Could anyone share their experiences on what you are using and how it is working for you?

    Read the article

  • How to use routing in a ASP MVC website to localize in two languages - But keeping exiting URLs

    - by Anders Pedersen
    We have a couple ASP MVC websites just using the standard VS templates default settings - Working as wanted. But now I want to localize these website ( They are now in Dutch and I will add the English language ) I would like to use routing and not Resource because: 1. Languages will differ in content, numbers of pages, etc. 2. The content is mostly text. I would like the URLs to look some thing like this - www.domain.com/en/Home/Index, www.domain.nl/nl/Home/Index. But the last one should also work with - www.domain.nl/Home/Index - Witch is the exciting URLs. I have implemented Phil Haacks areas ViewEngine from this blogpost - http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx. But only putting the English website in the areas and keeping the Dutch in old structure. Witch are served as Phils default fallback. But the problem is here that I have to duplicate my controllers for both language's. So I tried the work method described in this tread - http://stackoverflow.com/questions/1712167/asp-net-mvc-localization-route. It works OK with the ?en? and /nl/ but not with the old URLs. When using this code in the global.asax the URL without the culture isn't working. public static void RegisterRoutes(RouteCollection routes) { //routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{culture}/{controller}/{action}/{id}", // URL with parameters new { culture = "nl-NL", controller = "Home", action = "Index", id = "" } // Parameter defaults ); routes.MapRoute( "DefaultWitoutCulture", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } I properly overlooking some thing simple but I can't get this to work for me. Or are there a better way of doing this?

    Read the article

  • .NET: Preserving some, but not all query params during redirect

    - by kasper pedersen
    Hi all, Could someone tell me if the code below would achieve what I want, which is: Check if the query parameters 'return_path' and/or 'user_state' are present in the query string, and if so append them to the query string of the redirect URI. As I'm not a .NET dev and don't have a server to test this on, I was hoping someone could give me some feedback. ArrayList vars = new ArrayList(); vars.Add("return_path"); vars.Add("user_state"); string newUrl = "/new/request/uri" + "?"; ArrayList params = new ArrayList(); foreach ( string key in Request.QueryString ) { if (vars.contains(key)) { params.Add(key + "=" + HttpUtility.URLPathEncode(Request.QueryString[key])); } } String[] paramArr = (String[]) params.ToArray( typeof (string) ); String queryString = String.join("&", paramArr); Response.Redirect(newUrl); Thank you :)

    Read the article

  • I need a relatively cheap host, which will be able to handle sudden peaks in traffic?

    - by Morten K
    Hello, We're launching a product in a few months, which will obviously have a website. Judging from our current traffic, we believe that overall traffic will probably not be that much, but we are aiming at promoting the site heavily using social media. This has the typical problem, that IF we get suddenly get picked up by a large tech blog, we will see a sudden burst: A very heavy increase in traffic all of the sudden. If we use a cheap charlie host as our current host is (www.unoeuro.com) or something similar like GoDaddy, I'm afraid that the site will go down under the load. If that happens, then we might as well have thrown our social media marketing dollars out of the window. Our site will be relatively lightweight, all videos hosted at Youtube or Vimeo and other than that mainly just a standard webpage (ie nothing too heavy). I am hoping for recommendations for a good hosting company, which has some form of scalable hosting, so if / when a traffic surge hits, the site will not go down.

    Read the article

  • Iframe pages on Facebook does not show in Internet Explorer 9 - Windows 7 64-bit

    - by Morten
    Have this very irritating problem with Internet Explorer 9 and Facebook. If I go to Facebook and watch a page with iframes (like IFBML pages) it will not show up in Internet Explorer 9. It shows up in Firefox 4 and Chrome 10, but not in Internet Explorer 9. I run Windows 7 64-bit SP1 (danish). The strange thing is that I own three different PC´s and they all run Windows 64-bit SP1 and all of them has this issue. Can´t figure out what causes this issue. I have tried the following: Uninstalled AVG antivirus and installed Microsoft Antivirus - no change Updated Windows with SP1 - no change Updated from Internet Explorer 9 beta to Internet Explorer 9 final Ed. - no change Emptied cache and temp files in Internet Explorer 9 - no change Made www.facebook.com a trusted site in Internet Explorer 9 - no change And a lot of other things I can not remember I guess....but nothing seems to work. As I´m using quite a lot of my working time developing Facebook Fanpages it is frustrating not to be able to test them in Internet Explorer 9. BTW - it is Internet Explorer 9 32-bit - not 64-bit. Any clues?

    Read the article

  • NAT and NGINX on the same server

    - by Morten
    I'm setting up a VPC cluster for my collaborative todo list application www.getdoneapp.com. To have my servers on the private network I need a NAT server so my servers on the private network can connect to the internet to receive updates and what not. The NAT server will consume an elastic IP address, so I'm wondering if I can just have that NAT server run nginx to direct traffic to my internal servers for HTTP. So the question is, is it a bad idea to run NGINX and NAT on the same server, or should I go for consuming 2 elastic IP addresses?

    Read the article

  • Broadband Speed and What it Means to You

    However experienced the buyer, the one thing most broadband customers ask about is ?speed?. This is pretty much an umbrella term for how easy the functionality of your broadband connection and provid... [Author: Jakob Pedersen - Computers and Internet - April 01, 2010]

    Read the article

  • CUDA Driver API vs. CUDA runtime

    - by Morten Christiansen
    When writing CUDA applications, you can either work at the driver level or at the runtime level as illustrated on this image (The libraries are CUFFT and CUBLAS for advanced math): I assume the tradeoff between the two are increased performance for the low-evel API but at the cost of increased complexity of code. What are the concrete differences and are there any significant things which you cannot do with the high-level API? I am using CUDA.net for interop with C# and it is built as a copy of the driver API. This encourages writing a lot of rather complex code in C# while the C++ equivalent would be more simple using the runtime API. Is there anything to win by doing it this way? The one benefit I can see is that it is easier to integrate intelligent error handling with the rest of the C# code.

    Read the article

  • StructureMap - Scan - Generic Interface with base implementation and specific.

    - by Morten Schmidt
    Hi I have an interface something like this: interface IGenericSetupViewModel<T> I then have a default implemtation of this, something like this class GenericSetupViewModel<T> : IGenericSetupViewModel<T> For some specific classes i have a specific implementation like this: class ContractSetupViewModel : GenericSetupViewModel<Contract> Now i want to make StructureMap return the correct instance, when asking for a ObjectFactory.GetInstance<GenericSetupViewModel<Contract>(); I would like to get ContractSetupViewModel returned, when asking for anything else, i would like to get an instance of GenericSetupViewModel<T> I tried doing this: StructureMap.ObjectFactory.Configure(x => { x.Scan(y => { y.TheCallingAssembly(); y.AddAllTypesOf(typeof(IGenericSetupViewModel<>)); y.ConnectImplementationsToTypesClosing(typeof(IGenericSetupViewModel<>)); }); }); However this results in me always getting a GenericSetupViewModel and never the ContractSetupViewModel. I dont want to have to specify all specific viewmodels so is there anyway i can get this scan to work ?

    Read the article

  • How can I validate the result in an ASP.NET MVC editor template?

    - by Morten Christiansen
    I have created an editor template for representing selecting from a dynamic dropdown list and it works as it should except for validation, which I have been unable to figure out. If the model has the [Required] attribute set, I want that to invalidate if the default option is selected. The view model object that must be represented as the dropdown list is Selector: public class Selector { public int SelectedId { get; set; } public IEnumerable<Pair<int, string>> Choices { get; private set; } public string DefaultValue { get; set; } public Selector() { //For binding the object on Post } public Selector(IEnumerable<Pair<int, string>> choices, string defaultValue) { DefaultValue = defaultValue; Choices = choices; } } The editor template looks like this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <select class="template-selector" id="<%= ViewData.ModelMetadata.PropertyName %>.SelectedId" name="<%= ViewData.ModelMetadata.PropertyName %>.SelectedId"> <% var model = ViewData.ModelMetadata.Model as QASW.Web.Mvc.Selector; if (model != null) { %> <option><%= model.DefaultValue %></option><% foreach (var choice in model.Choices) { %> <option value="<%= choice.Value1 %>"><%= choice.Value2 %></option><% } } %> </select> I sort of got it to work by calling it from the view like this (where Category is a Selector): <%= Html.ValidationMessageFor(n => n.Category.SelectedId)%> But it shows the validation error for not supplying a proper number and it does not care if I set the Required attribute.

    Read the article

  • heroku mongohq and mongoid Mongo::ConnectionFailure

    - by Ole Morten Amundsen
    I have added the mongoHQ addon for mongodb at heroku. It crashes with something like this. connect_to_master': failed to connect to any given host:port (Mongo::ConnectionFailure) The descriptions online (heroku mongohq) are more directed towards mongomapper, as I see it. I'm running ruby 1.9.1 and rails 3-beta with mongoid. My feeling says that there's something with ENV['MONGOHQ_URL'], which it says the MongoHQ addon sets, but I haven't set MONGOHQ_URL anywhere in my app. I guess the problem is in my mongoid.yml ? defaults: &defaults host: localhost development: <<: *defaults database: aliado_development test: <<: *defaults database: aliado_test # set these environment variables on your prod server production: <<: *defaults host: <%= ENV['MONGOID_HOST'] %> port: <%= ENV['MONGOID_PORT'] %> username: <%= ENV['MONGOID_USERNAME'] %> password: <%= ENV['MONGOID_PASSWORD'] %> database: <%= ENV['MONGOID_DATABASE'] %> It works fine locally, but fails at heroku, more stack trace: ==> crashlog.log <== Cannot write to outdated .bundle/environment.rb to update it /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/rack-1.1.0/lib/rack.rb:14: warning: already initialized constant VERSION /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongo-0.20.1/lib/mongo/connection.rb:435:in `connect_to_master': failed to connect to any given host:port (Mongo::ConnectionFailure) from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongo-0.20.1/lib/mongo/connection.rb:112:in `initialize' from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4 /lib/mongoid/railtie.rb:32:in `new' from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4/lib/mongoid/railtie.rb:32:in `block (2 levels) in <class:Railtie>' from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4/lib/mongoid.rb:110:in `configure' from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4/lib/mongoid/railtie.rb:21:in `block in <class:Railtie>' from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/railties-3.0.0.beta3/lib/rails/initializable.rb:25:in `instance_exec' ..... It all works locally, both tests and app. I'm out of ideas... Any suggestions? PS: Somebody with high repu mind create the tag 'mongohq'?

    Read the article

  • Preventing sleep in Titanium for iPhone

    - by Morten J
    I'm trying to read the accelerometer for a longer period of time (between one and two hours). However, when the iPhone goes to sleep and locks, the reading of the accelerometer readout is paused. My setInterval timer seems to be running fine though. I can also play sounds. I see two solutions a) Find a way to read the accelerometer while locked b) Find a way to prevent the lock I'm using Titanium with JavaScript.

    Read the article

  • heroku time zone problem

    - by Ole Morten Amundsen
    Why does Time.now yield the server local time when I have set the another time zone in my environment.rb config.time_zone = 'Copenhagen' I've put this in a view <p> Time.zone <%= Time.zone %> </p> <p> Time.now <%= Time.now %> </p> <p> Time.now.utc <%= Time.now.utc %> </p> <p> Time.zone.now <%= Time.zone.now %> </p> <p> Time.zone.today <%= Time.zone.today %> </p> rendering this result on my app at heroku Time.zone (GMT+01:00) Copenhagen Time.now Mon Apr 26 08:28:21 -0700 2010 Time.now.utc Mon Apr 26 15:28:21 UTC 2010 Time.zone.now 2010-04-26 17:28:21 +0200 Time.zone.today 2010-04-26 Time.zone.now yields the correct result. Do I have to switch from Time.now to Time.zone.now, everywhere? Seems cumbersome. I truly don't care what the local time of the server is, it's giving me loads of trouble due to extensive use of Time.now. Am I misunderstanding anything fundamental here?

    Read the article

  • How to reset ASP.NET MVC client validation mode?

    - by Morten Christiansen
    I'm having a bit of trouble with the client-side validation in the ASP.NET MVC 2 framework and hope someone can help me out. In several situations I find it useful to be able to reset the contents of a form or just a single input element and I need any validation errors to disappear. This in itself is not very hard, and the suggestion provided here works well enough: http://stackoverflow.com/questions/2798427/how-do-i-clear-mvc-client-side-validation-errors-when-a-cancel-button-is-clicked The problem is that, when triggered, client validation goes into an aggressive mode that performs validation on each key press and when an input loses focus. Is there a good way to reset this state as well?

    Read the article

  • heroku time zone problem, logging local server time

    - by Ole Morten Amundsen
    UPDATE: Ok, I didn't formulate a good Q to be answered. I still struggle with heroku being on -07:00 UTC and I at +02:200 UTC. Q: How do I get the log written in the correct Time.zone ? The 9 hours difference, heroku (us west) - norway, is distracting to work with. I get this in my production.log (using heroku logs): Processing ProductionController#create to xml (for 81.26.51.35 at 2010-04-28 23:00:12) [POST] How do I get it to write 2010-04-29 08:00:12 +02:00 GMT ? Note that I'm running at heroku and cannot set the server time myself, as one could do at your amazon EC2 servers. Below is my previous question, I'll leave it be as it holds some interesting information about time and zones. Why does Time.now yield the server local time when I have set the another time zone in my environment.rb config.time_zone = 'Copenhagen' I've put this in a view <p> Time.zone <%= Time.zone %> </p> <p> Time.now <%= Time.now %> </p> <p> Time.now.utc <%= Time.now.utc %> </p> <p> Time.zone.now <%= Time.zone.now %> </p> <p> Time.zone.today <%= Time.zone.today %> </p> rendering this result on my app at heroku Time.zone (GMT+01:00) Copenhagen Time.now Mon Apr 26 08:28:21 -0700 2010 Time.now.utc Mon Apr 26 15:28:21 UTC 2010 Time.zone.now 2010-04-26 17:28:21 +0200 Time.zone.today 2010-04-26 Time.zone.now yields the correct result. Do I have to switch from Time.now to Time.zone.now, everywhere? Seems cumbersome. I truly don't care what the local time of the server is, it's giving me loads of trouble due to extensive use of Time.now. Am I misunderstanding anything fundamental here?

    Read the article

  • Using DotNetZip Library unzip file with non ASCII characters

    - by Morten Lyhr
    I'm trying to unzip a file, using DotNetZip Library. The file contains folders and files with danish characters (æøåÆØÅ). TotalCommander, 7Zip, Windows own zip all extract the files correctly, but DotNetZip Library mangles the danish characters. Ex: File_æøåÆØÅ.txt becomes File_æ¢åÆ¥Å.txt insted of aø it contains a ¢. insted of a Ø it contains a ¥. Code: using (var zipFile = ZipFile.Read(@"File_æøåÆØÅ.zip")) { zipFile.ExtractAll(@"File_æøåÆØÅ", ExtractExistingFileAction.OverwriteSilently); } I'm using the default encoding("da-DK" culture), I have tried other encodings like UTF8 etc. How can I unzip a file containing filenames with Danish characters?

    Read the article

  • How to add request validation errors to ModelStateDictionary in ASP.NET MVC?

    - by Morten Christiansen
    Investigating the security of a system I'm building with ASP.NET MVC 2 led me to discover the request validation feature of ASP.NET - a very neat feature, indeed. But obviously I don't just want to present the users with the Yellow Screen of Death when they enter data with HTML in, so I'm out to find a better solution. My idea is to find all the fields that have invalid data and add them to the ModelStateDictionary before invoking the action such that they automatically appear in the UI as error messages. After googling this a bit it appears that no one have implemented this before which I find puzzling since it seems so obvious. Does anyone here have a suggestion on how to do this? My own idea is to supply a custom ControllerActionInvoker to the controller, as described here, that somehow checks for this and modifies the ModelStateDictionary but I'm stuck on how to do this last bit. Just catching HttpRequestValidationException exceptions does not seem a useful approach since it does not actually contain all the information I need.

    Read the article

  • Android draw using SurfaceView and Thread

    - by Morten Høgseth
    I am trying to draw a ball to my screen using 3 classes. I have read a little about this and I found a code snippet that works using the 3 classes on one page, Playing with graphics in Android I altered the code so that I have a ball that is moving and shifts direction when hitting the wall like the picture below (this is using the code in the link). Now I like to separate the classes into 3 different pages for not making everything so crowded, everything is set up the same way. Here are the 3 classes I have. BallActivity.java Ball.java BallThread.java package com.brick.breaker; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class BallActivity extends Activity { private Ball ball; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); ball = new Ball(this); setContentView(ball); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); setContentView(null); ball = null; finish(); } } package com.brick.breaker; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.view.SurfaceHolder; import android.view.SurfaceView; public class Ball extends SurfaceView implements SurfaceHolder.Callback { private BallThread ballThread = null; private Bitmap bitmap; private float x, y; private float vx, vy; public Ball(Context context) { super(context); // TODO Auto-generated constructor stub bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ball); x = 50.0f; y = 50.0f; vx = 10.0f; vy = 10.0f; getHolder().addCallback(this); ballThread = new BallThread(getHolder(), this); } protected void onDraw(Canvas canvas) { update(canvas); canvas.drawBitmap(bitmap, x, y, null); } public void update(Canvas canvas) { checkCollisions(canvas); x += vx; y += vy; } public void checkCollisions(Canvas canvas) { if(x - vx < 0) { vx = Math.abs(vx); } else if(x + vx > canvas.getWidth() - getBitmapWidth()) { vx = -Math.abs(vx); } if(y - vy < 0) { vy = Math.abs(vy); } else if(y + vy > canvas.getHeight() - getBitmapHeight()) { vy = -Math.abs(vy); } } public int getBitmapWidth() { if(bitmap != null) { return bitmap.getWidth(); } else { return 0; } } public int getBitmapHeight() { if(bitmap != null) { return bitmap.getHeight(); } else { return 0; } } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // TODO Auto-generated method stub } public void surfaceCreated(SurfaceHolder holder) { // TODO Auto-generated method stub ballThread.setRunnable(true); ballThread.start(); } public void surfaceDestroyed(SurfaceHolder holder) { // TODO Auto-generated method stub boolean retry = true; ballThread.setRunnable(false); while(retry) { try { ballThread.join(); retry = false; } catch(InterruptedException ie) { //Try again and again and again } break; } ballThread = null; } } package com.brick.breaker; import android.graphics.Canvas; import android.view.SurfaceHolder; public class BallThread extends Thread { private SurfaceHolder sh; private Ball ball; private Canvas canvas; private boolean run = false; public BallThread(SurfaceHolder _holder,Ball _ball) { sh = _holder; ball = _ball; } public void setRunnable(boolean _run) { run = _run; } public void run() { while(run) { canvas = null; try { canvas = sh.lockCanvas(null); synchronized(sh) { ball.onDraw(canvas); } } finally { if(canvas != null) { sh.unlockCanvasAndPost(canvas); } } } } public Canvas getCanvas() { if(canvas != null) { return canvas; } else { return null; } } } Here is a picture that shows the outcome of these classes. I've tried to figure this out but since I am pretty new to Android development I thought I could ask for help. Does any one know what is causing the ball to be draw like that? The code is pretty much the same as the one in the link and I have tried to experiment to find a solution but no luck. Thx in advance for any help=)

    Read the article

  • Determine which mouse was clicked (multiple mice devices) in .NET

    - by Morten K
    Hi, I want to detect when my touchpad is clicked! I normally use a usb mouse, so I don't use the touchpad for anything. Instead I'd like to make it possible to perform an action in .NET, when the touchpad is clicked. This way I can use it as a shortcut: One tap and something cool happens. Is this possible, and if yes, any clue how? I'd prefer if it could be working in VB.NET or C#. My theory is that I'd have to make a mousehook, which then somehow determines which device the click is coming from. If the click is determined to be from the touchpad, then cancel the click and doWhatever(). Thanks!

    Read the article

< Previous Page | 1 2 3  | Next Page >