Search Results

Search found 1865 results on 75 pages for 'matt lacey'.

Page 32/75 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • MapItemsControls not updating Silverlight Bing Map

    - by Matt
    I'm using a MapItemsControl to control my Pushpin items within my Bing silverlight map. Right on the page load, I add a new pin programatically, and the pin shows up on the map. However I've now taken it further and I'm adding pins to my datasource via a click on the map. The new pins add to my datasource, but do not show up on the map. Do I need to rebind my datasource to my map control or somehow refresh the datasource? Here's some code <UserControl.Resources> <DataTemplate x:Key="PinData"> <m:Pushpin Location="{Binding Location}" PositionOrigin="BottomCenter" Width="Auto" Height="Auto" Cursor="Hand"> <m:Pushpin.Template> <ControlTemplate> <Grid> <myTestApp:MasterPin DataContext="{Binding}"/> </Grid> </ControlTemplate> </m:Pushpin.Template> </m:Pushpin> </DataTemplate> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <m:Map x:Name="myMap" CredentialsProvider="" Mode="Road" ScaleVisibility="Collapsed" > <m:MapItemsControl x:Name="mapItems" ItemTemplate="{StaticResource PinData}"/> </m:Map> </Grid> public partial class Map : UserControl { private List< BasePin > dataSource = new List< BasePin >(); public Map() { InitializeComponent(); _Initialize(); } private void _Initialize() { //this part works and adds a pin to the map dataSource.Add( new BaseSite( -33.881532, 18.440208 ) ); myMap.MouseClick += Map_MouseClick; mapItems.ItemsSource = dataSource; } public void Map_MouseClick(object sender, MapMouseEventArgs e)) { BasePin pin = new BasePin(); pin.Location = myMap.ViewportPointToLocation( e.ViewportPoint ); dataSource.Add( pin ); } }

    Read the article

  • CSS layout with 2 columns, taking up all width of browser, where left column can collapse

    - by Matt Dawdy
    I want to have a 2 column layout, and have the left column able to be 200 px at first, and have a "shrink" button to shrink it down to 10px, and have the right column expand to fill all the rest of the available space. Then if they click on the "show" button (which will be all they see in the now 10px wide left column) have the left grow back to 200px and have the right column shrink by that amount. I can't figure out how to make the right column grown and shrink without knowing the exact width of the window. I hope this makes sense, and I really hope someone can point me in the right direction. Browser requirements are IE8, FF3.6, Safari, and Chrome, so in theory I can use some advanced CSS techniques. At least I don't have to support IE6.

    Read the article

  • Silverlight Chat WrapPanel Crash / Bug

    - by Matt
    I've been given the task to create a simple Silverlight chat box for two people. My control must adhere to the following requirements Scrollable Text must wrap if it's too long When a new item / message is added it must scroll that item into view Now I've successfully made a usercontrol to meet these requirements, but I've run into a possible bug / crash that I can't for the life of me fix. I'm looking for either a fix to the bug, or a different approach to creating a scrollable chat control. Here's the code I've been using. We'll start with my XAML for the chat window <ListBox x:Name="lbChatHistory" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Disabled" > <ListBox.ItemTemplate> <DataTemplate> <Grid Background="Beige"> <Grid.ColumnDefinitions> <ColumnDefinition Width="70"></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition> </Grid.ColumnDefinitions> <TextBlock x:Name="lblPlayer" Foreground="{Binding ForeColor}" Text="{Binding Player}" Grid.Column="0"></TextBlock> <ContentPresenter Grid.Column="1" Width="200" Content="{Binding Message}" /> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> The idea is to add a new Item to the listbox. The Item (as layed out in the XAML) is a simple 2 column grid. One column for the username, and one column for the message. Now the "items" that I add to the ListBox is a custom class. It has three properties (Player, ForeColor, and Message) that I using binding on within my XAML Player is a string of the current user to display. ForeColor is just a foreground color preference. It helps distinguish the difference between messages. Message is a WrapPanel. I programmatically break the supplied string on the white space for each word. Then for each word, I add a new TextBlock element to the WrapPanel Here is the custom class. public class ChatMessage :DependencyObject, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public static DependencyProperty PlayerProperty = DependencyProperty.Register( "Player", typeof( string ), typeof( ChatMessage ), new PropertyMetadata( new PropertyChangedCallback( OnPlayerPropertyChanged ) ) ); public static DependencyProperty MessageProperty = DependencyProperty.Register( "Message", typeof( WrapPanel ), typeof( ChatMessage ), new PropertyMetadata( new PropertyChangedCallback( OnMessagePropertyChanged ) ) ); public static DependencyProperty ForeColorProperty = DependencyProperty.Register( "ForeColor", typeof( SolidColorBrush ), typeof( ChatMessage ), new PropertyMetadata( new PropertyChangedCallback( OnForeColorPropertyChanged ) ) ); private static void OnForeColorPropertyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) { ChatMessage c = d as ChatMessage; c.ForeColor = ( SolidColorBrush ) e.NewValue; } public ChatMessage() { Message = new WrapPanel(); ForeColor = new SolidColorBrush( Colors.White ); } private static void OnMessagePropertyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) { ChatMessage c = d as ChatMessage; c.Message = ( WrapPanel ) e.NewValue; } private static void OnPlayerPropertyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) { ChatMessage c = d as ChatMessage; c.Player = e.NewValue.ToString(); } public SolidColorBrush ForeColor { get { return ( SolidColorBrush ) GetValue( ForeColorProperty ); } set { SetValue( ForeColorProperty, value ); if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs( "ForeColor" )); } } public string Player { get { return ( string ) GetValue( PlayerProperty ); } set { SetValue( PlayerProperty, value ); if ( PropertyChanged != null ) PropertyChanged( this, new PropertyChangedEventArgs( "Player" ) ); } } public WrapPanel Message { get { return ( WrapPanel ) GetValue( MessageProperty ); } set { SetValue( MessageProperty, value ); if ( PropertyChanged != null ) PropertyChanged( this, new PropertyChangedEventArgs( "Message" ) ); } } } Lastly I add my items to the ListBox. Here's the simple method. It takes the above ChatMessage class as a parameter public void AddChatItem( ChatMessage msg ) { lbChatHistory.Items.Add( msg ); lbChatHistory.ScrollIntoView( msg ); } Now I've tested this and it all works. The problem I'm getting is when I use the scroll bar. You can scroll down using the side scroll bar or arrow keys, but when you scroll up Silverlight crashes. FireBug returns a ManagedRuntimeError #4004 with a XamlParseException. I'm soo close to having this control work, I can taste it! Any thoughts on what I should do or change? Is there a better approach than the one I've taken? Thanks in advance. UPDATE I've found an alternative solution using a ScrollViewer and an ItemsControl instead of a ListBox control. For the most part it's stable.

    Read the article

  • How to Prevent SelectionChange a Silverlight DataGrid

    - by Matt Eland
    I'm using a Silverlight 3 DataGrid control and have set the SelectionMode to Extended. The DataGrid takes care of managing the extended selection for me in an almost perfect manner out of the box, but a key piece of the logic is interfering with me. I have a cell that can function as a drag and drop thumb and initiate a drag operation but users want to do a series of shift or control clicks to set a selection followed by a click and drag on one of the selected rows to initiate the drag. The problem is that the click and drag at the end of this series causes the selection to be set to only the row that was clicked. I've poked around for ways of conditionally preventing the DataGrid from changing selection, but can't seem to find anything that works. Does anyone have any ideas for preventing selection from changing?

    Read the article

  • Using DateTime in a SqlParameter for Stored Procedure, format error

    - by Matt
    I'm trying to call a stored procedure (on a SQL 2005 server) from C#, .NET 2.0 using DateTime as a value to a SqlParameter. The SQL type in the stored procedure is 'datetime'. Executing the sproc from SQL Management Studio works fine. But everytime I call it from C# I get an error about the date format. When I run SQL Profiler to watch the calls, I then copy paste the exec call to see whats going on. These are my observations and notes about what I've attempted: 1) If I pass the DateTime in directly as a DateTime or converted to SqlDateTime, the field is surrounding by a PAIR of single quotes, such as @Date_Of_Birth=N''1/8/2009 8:06:17 PM'' 2) If I pass the DateTime in as a string, I only get the single quotes 3) Using SqlDateTime.ToSqlString() does not result in a UTC formatted datetime string (even after converting to universal time) 4) Using DateTime.ToString() does not result in a UTC formatted datetime string. 5) Manually setting the DbType for the SqlParameter to DateTime does not change the above observations. So, my questions then, is how on earth do I get C# to pass the properly formatted time in the SqlParameter? Surely this is a common use case, why is it so difficult to get working? I can't seem to convert DateTime to a string that is SQL compatable (e.g. '2009-01-08T08:22:45') EDIT RE: BFree, the code to actually execute the sproc is as follows: using (SqlCommand sprocCommand = new SqlCommand(sprocName)) { sprocCommand.Connection = transaction.Connection; sprocCommand.Transaction = transaction; sprocCommand.CommandType = System.Data.CommandType.StoredProcedure; sprocCommand.Parameters.AddRange(parameters.ToArray()); sprocCommand.ExecuteNonQuery(); } To go into more detail about what I have tried: parameters.Add(new SqlParameter("@Date_Of_Birth", DOB)); parameters.Add(new SqlParameter("@Date_Of_Birth", DOB.ToUniversalTime())); parameters.Add(new SqlParameter("@Date_Of_Birth", DOB.ToUniversalTime().ToString())); SqlParameter param = new SqlParameter("@Date_Of_Birth", System.Data.SqlDbType.DateTime); param.Value = DOB.ToUniversalTime(); parameters.Add(param); SqlParameter param = new SqlParameter("@Date_Of_Birth", SqlDbType.DateTime); param.Value = new SqlDateTime(DOB.ToUniversalTime()); parameters.Add(param); parameters.Add(new SqlParameter("@Date_Of_Birth", new SqlDateTime(DOB.ToUniversalTime()).ToSqlString())); Additional EDIT The one I thought most likely to work: SqlParameter param = new SqlParameter("@Date_Of_Birth", System.Data.SqlDbType.DateTime); param.Value = DOB; Results in this value in the exec call as seen in the SQL Profiler @Date_Of_Birth=''2009-01-08 15:08:21:813'' If I modify this to be @Date_Of_Birth='2009-01-08T15:08:21' It works, but it won't parse with pair of single quotes, and it wont convert to a datetime correctly with the space between the date and time and with the milliseconds on the end. Update and Success First and foremost, thank you everyone for the answers. I post this for the sake of completeness and accuracy on SO - because I certainly do not do it for my pride... I had copy/pasted the code above after the request from below. I trimmed things here and there to be concise. Turns out my problem was in the code I left out, which I'm sure any one of you would have spotted in an instant. I had wrapped my sproc calls inside a transaction. Turns out that I was simply not doing transaction.Commit()!!!!! I'm ashamed to say it, but there you have it. I still don't know what's going on with the syntax I get back from the profiler. A coworker watched with his own instance of the profiler from his computer, and it returned proper syntax. Watching the very SAME executions from my profiler showed the incorrect syntax. It acted as a red-herring, making me believe there was a query syntax problem instead of the much more simple and true answer, which was that I need to commit the transaction! I marked an answer below as correct, and threw in some up-votes on others because they did, after all, answer the question, even if they didn't fix my specific (brain lapse) issue. Thanks again for the help.

    Read the article

  • Delete a div id using ajax and jquery and delete from DB

    - by Matt Nathanson
    I've got several div id's, each containing a different client. I want to be able to click the delete button and using ajax and jquery delete the specific div from the database. I'm getting success in AJAX but it's not deleting anything from the DB. And then obviously, upon deletion, I would like the container to reload dynamically. help!!! function DeleteClient(){ var yes = confirm("Whoa there chief! Do you really want to DELETE this client?"); if (yes == 1) { dataToLoad = 'clientID=' + clientID + '&deleteclient=yes', $.ajax({ type: 'post', url: '/clients/controller.php', datatype: 'html', data: dataToLoad, success: function(html) { alert('Client' + clientID + ' should have been deleted from the database.'); $('#clientscontainer').html(html); }, error: function() { alert('error'); }});}; };

    Read the article

  • Integrating FedEx Web Services into .Net, stuck at step 1

    - by Matt Dawdy
    I'm signed up, I've downloaded sample code, I've got a WSDL...and yet I have no idea how to get this stuff into my existing .Net application. The WSDL was in a zip file, not a URL so I can't just "Add Web Reference." I've run the wsdl tool from the .Net command prompt, and it made a nice class for me...yet dropping that into my web_reference folder doesn't give me any kind of instantiatable class. I know I'm missing something stupid. Can someone point me in the right direction please?

    Read the article

  • Client WCF DataContract has empty/null values from service

    - by Matt
    I have a simple WCF service that returns the time from the server. I've confirmed that data is being sent by checking with Fiddler. Here's the result object xml that my service sends. <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetTimeResponse xmlns="http://tempuri.org/"> <GetTimeResult xmlns:a="http://schemas.datacontract.org/2004/07/TestService.DataObjects" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:theTime>2010-03-26T09:14:38.066372-06:00</a:theTime> </GetTimeResult> </GetTimeResponse> </s:Body> </s:Envelope> So, as far as I can tell, there's nothing wrong on the server end. It's receiving requests and returning results. But on my silverlight client, all the members of the returned object are either null, blank or a default vaule. As you can see the server returns the current date and time. But in silverlight, theTime property on my object is set to 1/1/0001 12:00 AM (default value). Sooo methinks that the DataContracts do not match up between the server and the silverlight client. Here's the DataContract for the server [DataContract] public class Time { [DataMember] public DateTime theTime { get; set; } } Incredibly simple. And here's the datacontract on my silverlight client. [DataContract] public class Time { [DataMember] public DateTime theTime { get; set; } } Literally the only difference is the namespaces within the application. But still the values being returned are null, empty or a .NET default. Thanks for you help!

    Read the article

  • Lucene search and underscores

    - by Matt
    When I use Luke to search my Lucene index using a standard analyzer, I can see the field I am searchng for contains values of the form MY_VALUE. When I search for field:"MY_VALUE" however, the query is parsed as field:"my value" Is there a simple way to escape the underscore (_) character so that it will search for it?

    Read the article

  • Bug Running Android Tutorial HelloTabWidget under SDK 1.5: "setCurrentTag(getIntent())"

    - by Matt J.
    does not compile. Indeed: even in 1.5, this api, getIntent(), is already listed as deprecated. The error message I get complains that getIntent() does not return a String, but setCurrentTab() expects a string. If I guess and change the line to read: "tabHost.setCurrentTab(1); // was setCurrentTab(getIntent())", then it compiles, builds, but does not run. I get the "stopped unexpectedly" error message from the emulator. I cannot even get Log.d to output, so it seems that it stops 'unexpectedly' very early. So the first and main question is: what is the correct fix to "tabHost.setCurrentTab(getIntent())" in the final line of OnCreate() in http://developer.android.com/resources/tutorials/views/hello-tabwidget.html? The second and simpler question is: did I guess right in replacing 'mTabHost' with tabHost in the one place where that occurs?

    Read the article

  • Response.Redirect with a fragment identifier causes unexpected refresh when later using location.has

    - by Matt
    Hi All, I was hoping someone can assist in describing a workaround solution to the following issue I am running into on my ASP.NET website on IE. In the following I will describe the bug and clarify the requirements of the needed solution. Repro Steps: User visits A.aspx A.aspx uses Response.Redirect to bring the user to B.aspx#house On B.aspx#house, the user clicks a button that sets window.location.hash='test' Actual Results: B.aspx is loaded again. The URL now shows B.aspx#test Expected Results: No reload. The URL will just change to B.aspx#test Requirements: Page A must redirect to page B with a fragment identifier in the url Any user action on page B will set the location.hash Setting location.hash must not make page B refresh This must work on IE Notes: Bug only repros on IE (tested on ie6|7|8). Opera, FF, Chrome, Safari all have the expected results of no reload. This error may have nothing to do with ASP.NET, and everything to do with IE For any kind soul willing to have a look at this, I have created a minimal ASP.NET web project to make it easy to repro here

    Read the article

  • Set android datepicker date limits

    - by matt
    I am using datePicker in android to display images based on user selected dates. I need to limit said dates to certain days for instance Jan 1st 2010 to Dec 31st 2010. Simple as that i thought but no where can i find the answer on how to limit these dates. Does anyone know how to limit the dates for Android DatePicker

    Read the article

  • Forms authentication in Silverlight

    - by Matt
    I have a website using forms authentication. Everything runs sweet their. I've got a Silverlight app that uses Duplex messaging to talk to a WCF service. I'd like to be able to authenticate users in my service. I realize that by doing this <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> that my service would then have access to the HttpContext.Current context and I could easily authenticate a user. But herein lies the problem. aspNetCompatibilityEnabled="true" combined with Duplex messaging results in very, very, very slow communication between silverlight and the website (10 seconds or more). Unless I have a configuration wrong, I'm going to assume that this is a bug in WCF / Silverlight. So basically I'm looking for a workaround. One idea I wanted to try was to read the ASPSESSID cookie from the browser and send that value over the wire. But I don't know what to do with the cookie on the service side. Is there some way to authenticate a user by sending their cookie data over duplex messaging?

    Read the article

  • Understanding the Silverlight Dispatcher

    - by Matt
    I had a Invalid Cross Thread access issue, but a little research and I managed to fix it by using the Dispatcher. Now in my app I have objects with lazy loading. I'd make an Async call using WCF and as usual I use the Dispatcher to update my objects DataContext, however it didn't work for this scenario. I did however find a solution here. Here's what I don't understand. In my UserControl I have code to call an Toggle method on my object. The call to this method is within a Dispatcher like so. Dispatcher.BeginInvoke( () => _CurrentPin.ToggleInfoPanel() ); As I mentioned before this was not enough to satisfy Silverlight. I had to make another Dispatcher call within my object. My object is NOT a UIElement, but a simple class that handles all its own loading/saving. So the problem was fixed by calling Deployment.Current.Dispatcher.BeginInvoke( () => dataContext.Detail = detail ); within my class. Why did I have to call the Dispatcher twice to achieve this? Shouldn't a high-level call be enough? Is there a difference between the Deployment.Current.Dispatcher and the Dispatcher in a UIElement?

    Read the article

  • Combine multiple dataset columns to one dataset

    - by Matt
    I have multiple datasets that I would like to combine into one. There is a common ID field that can be associated to each row. Calling Merge on the dataset will add additional rows to the dataset, but I would like to combine the additional columns. There are too many fields to do this in one query and therefore would make it unmanageable. Each individual query would be able to handle ordering to ensure the data is placed in the correct row. For Example lets say I have two queries resulting in two datasets: SELECT ID, colA, colB SELECT colC, colD The resulting dataset would look like ID colA colB colC colD 1 a b c d 2 e f g h Any ideas on ways to accomplish this?

    Read the article

  • Chaining IQueryables together

    - by Matt Greer
    I have a RIA Services based app that is using Entity Framework on the server side (possibly not relevant). In my real app, I can do something like this. EntityQuery<Status> query = statusContext.GetStatusesQuery().Where(s => s.Description.Contains("Foo")); Where statusContext is the client side subclass of DomainContext that RIA Services was kind enough to generate for me. The end result is an EntityQuery<Status> object who's Query property is an object that implements IQueryable and represents my where clause. The WebDomainClient is able to take this EntityQuery and not just give me back all of my Statuses but also filtered with my where clause. I am trying to implement this in a mock DomainClient. This MockDomainClient accepts an IQueryably<Entity> which it returns when asked for. But what if the user makes the query and includes the ad hoc additional query? How can I merge the two together? My MockDomainClient is (this is modeled after this blog post) ... public class MockDomainClient : LocalDomainClient { private IQueryable<Entity> _entities; public MockDomainClient(IQueryable<Entity> entities) { _entities = entities; } public override IQueryable<Entity> DoQuery(EntityQuery query) { if (query.Query == null) { return _entities; } // otherwise want the union of _entities and query.Query, query.Query is IQueryable // the below does not work and was a total shot in the dark: //return _entities.Union(query.Query.Cast<Entity>()); } } public abstract class LocalDomainClient : System.ServiceModel.DomainServices.Client.DomainClient { private SynchronizationContext _syncContext; protected LocalDomainClient() { _syncContext = SynchronizationContext.Current; } ... public abstract IQueryable<Entity> DoQuery(EntityQuery query); protected override IAsyncResult BeginQueryCore(EntityQuery query, AsyncCallback callback, object userState) { IQueryable<Entity> localQuery = DoQuery(query); LocalAsyncResult asyncResult = new LocalAsyncResult(callback, userState, localQuery); _syncContext.Post(o => (o as LocalAsyncResult).Complete(), asyncResult); return asyncResult; } ... }

    Read the article

  • Scrollable Wrappanel in Silverlight

    - by Matt
    How do I make a Wrappanel scrollable? Here's the XAML that I've been using but I get errors with it. <ItemsControl x:Name="lbMedia"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <c:WrapPanel></c:WrapPanel> </ScrollViewer> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <im:MediaManagerItem></im:MediaManagerItem> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>

    Read the article

  • Silverlight - Binding ImageSource to Rectangle Fill

    - by Matt.M
    Blend 4 is telling me this is invalid markup and its not telling me why: <ImageBrush Stretch="Fill" ImageSource="{Binding Avatar, Mode=OneWay}"/> I'm pulling data from a Twitter feed, saving to an ImageSource, and then binding it to an ImageBrush(as seen below) to be used as the Fill for a Rectangle. Here is more context: <Rectangle x:Name="Avatar" RadiusY="9" RadiusX="9" Width="45" Height="45" VerticalAlignment="Center" HorizontalAlignment="Center" > <Rectangle.Fill> <ImageBrush Stretch="Fill" ImageSource="{Binding Avatar, Mode=OneWay}"/> </Rectangle.Fill> </Rectangle> I'm using this inside of a Silverlight UserControl, which is used inside of a Silverlight Application. Any Ideas on what the problem could be?

    Read the article

  • 404 Error - HEAD request on default page

    - by Matt
    I am working on a project where we are about to go to internal release. So we are working to clean up the small problems before then. I was looking at our logs and noticed a high number of 404 errors. On further inspection it seems that all of them are related to HEAD requests. I haven't been able to find any substantive information about the preferred method for handling this in a standards compliant manner. Is there anything out there that can point out the proper way to handle that.

    Read the article

  • Android: retrieving all Drawable resources from Resources object

    - by Matt Huggins
    In my Android project, I want to loop through the entire collection of Drawable resources. Normally, you can only retrieve a specific resource via its ID using something like: InputStream is = Resources.getSystem().openRawResource(resourceId) However, I want to get all Drawable resources where I won't know their ID's beforehand. Is there a collection I can loop through or perhaps a way to get the list of resource ID's given the resources in my project? Or, is there a way for me in Java to extract all property values from the R.drawable static class?

    Read the article

  • Maze not being random.

    - by Matt Habel
    Hey there, I am building a program that generates a maze so I can later translate the path to my graphical part. I have most of it working, however, every time you can just take the east and south routes, and you'll get to the end. Even if I set the width as high as 64, so the maze is 64*64, I'm able to choose those 2 options and get to the end every time. I really don't understand why it is doing that. The code is below, it's fairly easy to understand. import random width = 8 def check(x,y): """Figures out the directions that Gen can move while""" if x-1 == -1: maze[x][y][3] = 0 if x+1 == width + 1: maze[x][y][1] = 0 if y+1 == width + 1: maze[x][y][2] = 0 if y-1 == -1: maze[x][y][0] = 0 if x + 1 in range(0,width) and visited[x+1][y] == False: maze[x][y][1] = 2 if x - 1 in range(0,width) and visited[x-1][y] == False: maze[x][y][3] = 2 if y + 1 in range(0,width) and visited[x][y+1] == False: maze[x][y][2] = 2 if y - 1 in range(0,width) and visited[x][y-1] == False: maze[x][y][0] = 2 def possibleDirs(x,y): """Figures out the ways that the person can move in each square""" dirs = [] walls = maze[x][y] if walls[0] == 1: dirs.append('n') if walls[1] == 1: dirs.append('e') if walls[2] == 1: dirs.append('s') if walls[3] == 1: dirs.append('w') return dirs def Gen(x,y): """Generates the maze using a depth-first search and recursive backtracking.""" visited[x][y] = True dirs = [] check(x,y) if maze[x][y][0] == 2: dirs.append(0) if maze[x][y][1] == 2: dirs.append(1) if maze[x][y][2] == 2: dirs.append(2) if maze[x][y][3] == 2: dirs.append(3) print dirs if len(dirs): #Randonly selects a derection for the current square to move past.append(current[:]) pos = random.choice(dirs) maze[x][y][pos] = 1 if pos == 0: current[1] -= 1 maze[x][y-1][2] = 1 if pos == 1: current[0] += 1 maze[x+1][y][3] = 1 if pos == 2: current[1] += 1 maze[x][y+1][0] = 1 if pos == 3: current[0] -= 1 maze[x-1][y][1] = 1 else: #If there's nowhere to go, go back one square lastPlace = past.pop() current[0] = lastPlace[0] current[1] = lastPlace[1] #Build the initial values for the maze to be replaced later maze = [] visited = [] past = [] #Generate empty 2d list with a value for each of the xy coordinates for i in range(0,width): maze.append([]) for q in range(0, width): maze[i].append([]) for n in range(0, 4): maze[i][q].append(4) #Makes a list of falses for all the non visited places for x in range(0, width): visited.append([]) for y in range(0, width): visited[x].append(False) dirs = [] print dirs current = [0,0] #Generates the maze so every single square has been filled. I'm not sure how this works, as it is possible to only go south and east to get to the final position. while current != [width-1, width-1]: Gen(current[0], current[1]) #Getting the ways the person can move in each square for i in range(0,width): dirs.append([]) for n in range(0,width): dirs[i].append([]) dirs[i][n] = possibleDirs(i,n) print dirs print visited pos = [0,0] #The user input part of the maze while pos != [width - 1, width - 1]: dirs = [] print pos if maze[pos[0]][pos[1]][0] == 1: dirs.append('n') if maze[pos[0]][pos[1]][1] == 1: dirs.append('e') if maze[pos[0]][pos[1]][2] == 1: dirs.append('s') if maze[pos[0]][pos[1]][3] == 1: dirs.append('w') print dirs path = raw_input("What direction do you want to go: ") if path not in dirs: print "You can't go that way!" continue elif path.lower() == 'n': pos[1] -= 1 elif path.lower() == 'e': pos[0] += 1 elif path.lower() == 's': pos[1] += 1 elif path.lower() == 'w': pos[0] -= 1 print"Good job!" As you can see, I think the problem is at the point where I generate the maze, however, when I just have it go until the current point is at the end, it doesn't fill every maze and is usually just one straight path. Thanks for helping. Update: I have changed the for loop that generates the maze to a simple while loop and it seems to work much better. It seems that when the for loop ran, it didn't go recursively, however, in the while loop it's perfectly fine. However, now all the squares do not fill out.

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >