Search Results

Search found 12 results on 1 pages for 'thecloudlesssky'.

Page 1/1 | 1 

  • Spatial Index for Rectangles With Fast Insert

    - by TheCloudlessSky
    Hello, I'm looking for a data structure that provides indexing for Rectangles. I need the insert algorithm to be as fast as possible since the rectangles will be moving around the screen (think of dragging a rectangle with your mouse to a new position). I've looked into R-Trees, R+Trees, kD-Trees, Quad-Trees and B-Trees but from my understanding insert's are usually slow. I'd prefer to have inserts at sub-linear time complexity so maybe someone can prove me wrong about either of the listed data structures. I should be able to query the data structure for what rectangles are at point(x, y) or what rectangles intersect rectangle(x, y, width, height). EDIT: The reason I want insert so fast is because if you think of a rectangle being moved around the screen, they're going to have to be removed and then re-inserted. Thanks!

    Read the article

  • C# Pass Generics At Runtime

    - by TheCloudlessSky
    I have a method like the following: public IEnumerable<T> GetControls<T>() : where T : ControlBase { // removed. } I then created a class: public class HandleBase<TOwner> : ControlBase : TOwner { // Removed } I'd like to be able to call GetControls<HandleBase<this.GetType()>>; where it would use the type of THIS class to pass to the HandleBase. This would in essentially get all HandleBase that have an owner of THIS type. How can I achieve this?

    Read the article

  • Bitfield With 3 States...?

    - by TheCloudlessSky
    I'm trying to create an authorization scheme for my ASP.NET MVC application where an Enum is used to set permissions. For example: [Flags] enum Permissions { ReadAppointments = 1, WriteAppointments = 2 | ReadAppointments, ReadPatients = 4, WritePatients = 8 | ReadPatients, ReadInvoices = 16, WriteInvoices = 32 | ReadInvoices ... } But I don't really like that because it really doesn't make it clear that Write always includes Read. I then realized that a requirement would be that a user might have NO access to, for example, Appointments. Essentially, I'd want a "bitfield" with 3 states: none, readonly, full (read/write). I'd like to still use an enum bitfield since it's easy to store in a DB (as an int). Also it's very easy to see if a permission is set. Does anyone have any idea how this could be easily accomplished using an Enum... or am I going in the completely wrong direction?

    Read the article

  • C# Generics Question

    - by TheCloudlessSky
    Would it be possible to do something like the following in c#? Basically TParent and TChildren should be types of the class A but not necessairly have the same types that were passed in. I know this may sound confusing but I want to strongly type the children and parents of a particular object, but at the same time they must be of the same type. Because TParent inherits from A this would imply that it requires type parameters that inherit from A but using potentially different types. public class A<TParent, TChildren> where TParent : A where TControls : A { TParent Parent; List<TChildren> Children; } or more easily seen here: public class A<TParent, TChildren> where TParent : A<?, ?> where TChildren : A<?, ?> { TParent Parent; List<TChildren> Children; } I hope this isn't too confusing. Is this at all possible? Thanks :)

    Read the article

  • Visual Studio 2008 Navigate Forewards/Backwards Buttons Don't Work As Expected

    - by TheCloudlessSky
    I just installed VS2008 on my new Win7 box. I have Navigate Backwards and Navigate Forwards buttons on my tool bar. When I change between documents, I do NOT see a list drop down for each of the buttons like should be seen here after opening multiple documents and switching between their methods: How it should work. Instead, I just see the buttons without drop downs. I find that navigating forwards and backwards doesn't work as it should. I should be able to click in different lines of the code and press the nav back/forwards buttons to jump between lines. This is not the case. Any suggestions? Thanks in advanced. PS - I installed SP1 just to see and nothing changed.

    Read the article

  • How to Implement AutoSize

    - by TheCloudlessSky
    I'm trying to figure out a good way to auto-size a Rectangle that has text drawn inside of it. I basically want the size to have a ratio of width/height and then "grow" according to that ratio to fit the text. I've looked at Graphics.MeasureString but I don't think it does what I'm looking for (maybe it does and I'm just using it wrong). I don't want to specify a specific width of the rectangle to be drawn, instead I want to say find the smallest width/height to fit this text but the found rectangle must have some specific ratio of width and height. This doesn't have to be specific to C#, any idea for solving this problem I'm sure can be mapped to C#. Thanks!

    Read the article

  • Can entities be attached to an ISession that weren't previously attached?

    - by TheCloudlessSky
    I'm playing around with NHibernate 3.0. So far things are pretty cool. I'm trying to attach an entity that wasn't detached previously: var post = new Post(){ Id = 2 } session.Update(post); // Thought this would work but it doesn't. post.Title = "New Title After Update"; session.Flush(); Is this possible so that only Title gets updated? This is currently possible in EntityFramework. I'd like to not have to load Post from the database when I just need to update a few properties.

    Read the article

  • How to align all fields as label width grows

    - by TheCloudlessSky
    I have a form where the labels are on the left and the fields on the right. This layout works great when the labels have small amounts of text. I can easily set a min-width on the labels to ensure they all have the same distance to the fields. In the first picture below, this works as expected. A problem arises when the label's text becomes too long, it'll either overflow to the next line or push the field on the same line over to the left (as seen in picture 2). This doesn't push the other labels so it is left with a "jagged" look. Ideally, it should like to style it as picture 3 with something like the following markup: <fieldset> <label>Name</label><input type="text" /><br /> <label>Username</label><input type="text" /> </fieldset> I created a jsFiddle to show the issue. Of course, the easy cross-browser way to solve this would be to use tables. That just creates tag-hell for something that should be so simple. Note: this does not need to support IE6.

    Read the article

  • How does OfType<T>() Work?

    - by TheCloudlessSky
    How does OfType() Work? I read this link about what's going on but how exactly does the LINQ provider know how to get all objects matching the specified type. I know the IQueryable<T> "chains" up requests and then evaluates when GetEnumerator() is called (right?). Specifically I want to know how does the framework quickly do type comparison? I wrote a method in a .NET 2.0 project that went like this (since 2.0 doesn't support these kind of features): public IEnumerable<TResult> OfType<TResult>() where TResult : class { foreach (TItem item in this.InnerList) { TResult matchItem = item as TResult; if (matchItem != null) { yield return matchItem; } } } Is this the best implementation?

    Read the article

  • Can AutoMapper create a map for an interface and then map with a derived type?

    - by TheCloudlessSky
    I have an interface IFoo: public interface IFoo { int Id { get; set; } } And then a concrete implementation: public class Bar : IFoo { public int Id { get; set; } public string A { get; set; } } public class Baz : IFoo { public int Id { get; set; } public string B { get; set; } } I'd like to be able to map all IFoo but specifying their derived type instead: Mapper.CreateMap<int, IFoo>().AfterMap((id, foo) => foo.Id = id); And then map (without explicitly creating maps for Bar and Baz): var bar = Mapper.Map<int, Bar>(123); // bar.Id == 123 var baz = Mapper.Map<int, Baz>(456); // baz.Id == 456 But this doesn't work in 1.1. I know I could specify all Bar and Baz but if there are 20 of these, I'd like to not have to manage them and rather just have what I did above for creating the map. Is this possible?

    Read the article

  • Mocking ISession.Query<T>() for testing consumer

    - by TheCloudlessSky
    I'm trying to avoid using an in memory database for testing (though I might have to do this if the following is impossible). I'm using NHibernate 3.0 with LINQ. I'd like to be able to mock session.Query<T>() to return some dummy values but I can't since it's an extension method and these are pretty much impossible to test. Does anyone have any suggestions (other than using an in memory database) for testing session queries with LINQ?

    Read the article

1