Search Results

Search found 1725 results on 69 pages for 'andrew stacey'.

Page 6/69 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • jquery event listening, non-standard events

    - by Stacey
    I'm attempting to build a way for my selectors to 'listen' to 'global' events that are beyond the typical 'click' 'change' 'submit' etc. I've explored the various 'eventmanagers' that I could find, and they're all still designed for forms. Is there any way to do something like this for non-standard (i.e. custom) events? The goal is to have selectors subscribe to an event, and then be able to trigger it in one place and it will raise it for everything subscribed to it.

    Read the article

  • Collectable<T> serialization, Root Namespaces on T in .xml files.

    - by Stacey
    I have a Repository Class with the following method... public T Single<T>(Predicate<T> expression) { using (var list = (Models.Collectable<T>)System.Xml.Serializer.Deserialize(typeof(Models.Collectable<T>), FileName)) { return list.Find(expression); } } Where Collectable is defined.. [Serializable] public class Collectable<T> : List<T>, IDisposable { public Collectable() { } public void Dispose() { } } And an Item that uses it is defined.. [Serializable] [System.Xml.Serialization.XmlRoot("Titles")] public partial class Titles : Collectable<Title> { } The problem is when I call the method, it expects "Collectable" to be the XmlRoot, but the XmlRoot is "Titles" (all of object Title). I have several classes that are collected in .xml files like this, but it seems pointless to rewrite the basic methods for loading each up when the generic accessors do it - but how can I enforce the proper root name for each file without hard coding methods for each one? The [System.Xml.Serialization.XmlRoot] seems to be ignored.

    Read the article

  • constructorless initialization and Dictionaries

    - by Stacey
    Using C# 3.0, we can initialize objects without their constructors for syntactical reasons. Such as .. ClassName c = new ClassName = { Property1 = "Value" } I was wondering how this works with Dictionaries and adding the items to them. Any ideas? class Foo { public Dictionary DictionaryObject { get; set; } } Foo f = new Foo = { // ??? } Thank you for your time!!

    Read the article

  • Partially Modifying an XML serialized document.

    - by Stacey
    I have an XML document, several actually, that will be editable via a front-end UI. I've discovered a problem with this approach (other than the fact that it is using xml files instead of a database... but I cannot change that right now). If one user makes a change while another user is in the process of making a change, then the second one's changes will overwrite the first. I need to be able to request objects from the xml files, change them, and then submit the changes back to the xml file without re-writing the entire file. I've got my entire xml access class posted here (which was formed thanks to wonderful help from stackoverflow!) using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace Repositories { /// <summary> /// A file base repository represents a data backing that is stored in an .xml file. /// </summary> public partial class Repository<T> : IRepository { /// <summary> /// Default constructor for a file repository /// </summary> public Repository() { } /// <summary> /// Initialize a basic repository with a filename. This will have to be passed from a context to be mapped. /// </summary> /// <param name="filename"></param> public Repository(string filename) { FileName = filename; } /// <summary> /// Discovers a single item from this repository. /// </summary> /// <typeparam name="TItem">The type of item to recover.</typeparam> /// <typeparam name="TCollection">The collection the item belongs to.</typeparam> /// <param name="expression"></param> /// <returns></returns> public TItem Single<TItem, TCollection>(Predicate<TItem> expression) where TCollection : IDisposable, IEnumerable<TItem> { using (var list = List<TCollection>()) { return list.Single(i => expression(i)); } } /// <summary> /// Discovers a collection from the repository, /// </summary> /// <typeparam name="TCollection"></typeparam> /// <returns></returns> public TCollection List<TCollection>() where TCollection : IDisposable { using (var list = System.Xml.Serializer.Deserialize<TCollection>(FileName)) { return (TCollection)list; } } /// <summary> /// Discovers a single item from this repository. /// </summary> /// <typeparam name="TItem">The type of item to recover.</typeparam> /// <typeparam name="TCollection">The collection the item belongs to.</typeparam> /// <param name="expression"></param> /// <returns></returns> public List<TItem> Select<TItem, TCollection>(Predicate<TItem> expression) where TCollection : IDisposable, IEnumerable<TItem> { using (var list = List<TCollection>()) { return list.Where( i => expression(i) ).ToList<TItem>(); } } /// <summary> /// Attempts to save an entire collection. /// </summary> /// <typeparam name="TCollection"></typeparam> /// <param name="collection"></param> /// <returns></returns> public Boolean Save<TCollection>(TCollection collection) { try { // load the collection into an xml reader and try to serialize it. System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); xDoc.LoadXml(System.Xml.Serializer.Serialize<TCollection>(collection)); // attempt to flush the file xDoc.Save(FileName); // assume success return true; } catch { return false; } } internal string FileName { get; private set; } } public interface IRepository { TItem Single<TItem, TCollection>(Predicate<TItem> expression) where TCollection : IDisposable, IEnumerable<TItem>; TCollection List<TCollection>() where TCollection : IDisposable; List<TItem> Select<TItem, TCollection>(Predicate<TItem> expression) where TCollection : IDisposable, IEnumerable<TItem>; Boolean Save<TCollection>(TCollection collection); } }

    Read the article

  • Dismiss Menu when Focus is lost, not on mouseout. jQuery

    - by Stacey
    I have jQuery that drops a menu down when its parent is clicked on, and dismisses it when they hover away from the menu. I am wanting to change the behavior so that it only dismisses if they click somewhere else on the page, or a different menu. Is this possible? jQuery.fn.dropdown = function () { return this.each(function () { $('.ui-dropdown-list > li > a').click(function () { $(this).addClass("ui-dropdown-hover"); }); $("ul.ui-dropdown-list > li > a").click(function () { $(this).parent().find("ul").show(); $(this).parent().hover(function () { }, function () { $(this).parent().find("ul").hide(); $(this).find('> a').removeClass("ui-dropdown-hover"); }); }); }); };

    Read the article

  • LINQ - Splitting up a string with maximum length, but not chopping words apart.

    - by Stacey
    I have a simple LINQ Extension Method... public static IEnumerable<string> SplitOnLength(this string input, int length) { int index = 0; while (index < input.Length) { if (index + length < input.Length) yield return input.Substring(index, length); else yield return input.Substring(index); index += length; } } This takes a string, and it chops it up into a collection of strings that do not exceed the given length. This works well - however I'd like to go further. It chops words in half. I don't need it to understand anything complicated, I just want it to be able to chop a string off 'early' if cutting it at the length would be cutting in the middle of text (basically anything that isn't whitespace). However I suck at LINQ, so I was wondering if anyone had an idea on how to go about this. I know what I am trying to do, but I'm not sure how to approach it. So let's say I have the following text. This is a sample block of text that I would pass through the string splitter. I call this method SplitOnLength(6) I would get the following. This i s a sa mple b lock o f text that I would pass t hrough the s tring splitt er. I would rather it be smart enough to stop and look more like .. This is a sample // bad example, since the single word exceeds maximum length, but the length would be larger numbers in real scenarios, closer to 200. Can anyone help me?

    Read the article

  • IRepository with Inherited Classes

    - by Stacey
    In keeping with the Repository pattern of data input, I've a question in regards to using inherited classes. For instance, suppose I would have the class... class Employee IEmployeeRepository { Add(Employee employee); } This works fine, nothing wrong with it so far... but now let's say I continue on.. class Manager : Employee Okay, now let's assume that I never need to enter a manager different than an Employee? What's the best approach here? Would a scenario such as .. IEmployeeRepository { Add<T>(T employee) where T : Employee } Be the best approach, or do I need to abstract a different repository for each type?

    Read the article

  • Faster Javascript text replace

    - by Stacey
    Given the following javascript (jquery) $("#username").keyup(function () { selected.username = $("#username").val(); var url = selected.protocol + (selected.prepend == true ? selected.username : selected.url) + "/" + (selected.prepend == true ? selected.url : selected.username); $("#identifier").val(url); }); This code basically reads a textbox (username), and when it is typed into, it reconstructs the url that is being displayed in another textbox (identifier). This works fine - there are no problems with its functionality. However it feels 'slow' and 'sluggish'. Is there a cleaner/faster way to accomplish this task? Here is the HTML as requested. <fieldset class="identifier delta"> <form action="/authenticate/openid" method="post" target="_top" > <input type="text" class="openid" id="identifier" name="identifier" readonly="readonly" /> <input type='text' id='username' name='username' class="left" style='display: none;'/> <input type="submit" value="Login" style="height: 32px; padding-top: 1px; margin-right: 0px;" class="login right" /> </form> </fieldset> The identifier textbox just has a value set based on the hyperlink anchor of a button.

    Read the article

  • jquery .blur for entire block of HTML

    - by Stacey
    I have an HTML item for a 'drop down menu', structured like this... <li class="ui-dropdown-list" > <a href="#">Right Drop Down Menu</a> <ul> <li><a href="#">Item</a></li> <li><a href="#">Item</a></li> <li><a href="#">Item</a></li> </ul> </li> Using jQuery to make this a dropdown list, with the following code. jQuery.fn.dropdown = function () { var defaults = { button: null, menu: null, visible: false }; var options = $.extend(defaults, options); return this.each(function () { options.button = $(this); options.menu = $(this).find("ul"); // when the parent is clicked, determine whether dropdown needs to occur options.button.click(function () { options.visible ? lift(options.menu) : drop(options.menu); options.visible = !options.visible; }); // drop the menu down so that it can be seen. function drop(e) { options.button.addClass("open"); options.menu.show(); } // lift the menu up, hiding it from view. function lift(e) { options.menu.hide(); options.button.removeClass('open'); } }); }; I am trying to wire it up so that if the user clicks anywhere outside of the menu, it will collapse it. This is proving much more difficult than I anticipated; even trying to use page level events. Any suggestions? The menu itself never really 'receives' focus, so using .blur doesn't seem to be suiting the purpose.

    Read the article

  • Implementing IEnumeralbe on Non-Listed Items

    - by Stacey
    I have a class that contains a static number of objects. This class needs to be frequently 'compared' to other classes that will be simple List objects. public partial class Sheet { public Item X{ get; set; } public Item Y{ get; set; } public Item Z{ get; set; } } the items are obviously not going to be "X" "Y" "Z", those are just generic names for example. The problem is that due to the nature of what needs to be done, a List won't work; even though everything in here is going to be of type Item. It is like a checklist of very specific things that has to be tested against in both code and runtime. This works all fine and well; it isn't my issue. My issue is iterating it. For instance I want to do the following... List<Item> UncheckedItems = // Repository Logic Here. UncheckedItems contains all available items; and the CheckedItems is the Sheet class instance. CheckedItems will contain items that were moved from Unchecked to Checked; however due to the nature of the storage system, items moved to Checked CANNOT be REMOVED from Unchecked. I simply want to iterate through "Checked" and remove anything from the list in Unchecked that is already in "Checked". So naturally, that would go like this with a normal list. foreach(Item item in Unchecked) { if( Checked.Contains(item) ) Unchecked.Remove( item ); } But since "Sheet" is not a 'List', I cannot do that. So I wanted to implement IEnumerable so that I could. Any suggestions? I've never implemented IEnumerable directly before and I'm pretty confused as to where to begin.

    Read the article

  • Trouble with SVN and Filename 'changes'.

    - by Stacey
    I am programming in Visual Studio 2010, using TortiseSVN and VisualSVN as my client to connect to SVN repositories. I am having a bit of a frequent problem though with the whole SVN thing in general. One thing that keeps cropping up is that if I make changes to files - namely filenames, or move them to new folders, etc, I end up getting all kinds of conflicts with the repository and it just causes all sorts of strange errors. I understand the importance of version control and check-in/check-out access like this, but what do most of you do to deal with this kind of thing? I mean, I've tried doing the whole 'Remove from Subversion', change my file, then 'Add to Subversion' thing, and it just doesn't seem to do the job very well. This is especially frustrating when working on web projects where filenames can change very frequently as a project evolves and becomes multifaceted. Are there any standard ways to deal with this kind of thing, or is it just one of the flaws of SVN in general?

    Read the article

  • How do I implement IEnumerable?

    - by Stacey
    I have a class that contains a static number of objects. This class needs to be frequently 'compared' to other classes that will be simple List objects. public partial class Sheet { public Item X{ get; set; } public Item Y{ get; set; } public Item Z{ get; set; } } the items are obviously not going to be "X" "Y" "Z", those are just generic names for example. The problem is that due to the nature of what needs to be done, a List won't work; even though everything in here is going to be of type Item. It is like a checklist of very specific things that has to be tested against in both code and runtime. This works all fine and well; it isn't my issue. My issue is iterating it. For instance I want to do the following... List<Item> UncheckedItems = // Repository Logic Here. UncheckedItems contains all available items; and the CheckedItems is the Sheet class instance. CheckedItems will contain items that were moved from Unchecked to Checked; however due to the nature of the storage system, items moved to Checked CANNOT be REMOVED from Unchecked. I simply want to iterate through "Checked" and remove anything from the list in Unchecked that is already in "Checked". So naturally, that would go like this with a normal list. foreach(Item item in Unchecked) { if( Checked.Contains(item) ) Unchecked.Remove( item ); } But since "Sheet" is not a 'List', I cannot do that. So I wanted to implement IEnumerable so that I could. Any suggestions? I've never implemented IEnumerable directly before and I'm pretty confused as to where to begin.

    Read the article

  • Include HTML file as embedded resource

    - by Stacey
    A followup to another question I did, I've done some more digging but I am still coming up dry. Is there any way to include .HTML/.ASPX files as 'embedded resources' into an ASP.NET MVC application? I've found lots of examples of using string resources, but never other files entirely.

    Read the article

  • Calling inheriting class methods via interface.

    - by Stacey
    Given the scenario... interface IBase{ void Process(int value); } abstract class Base : IBase { public virtual void Process(int value){ throw new NotImplementedException(); } } class Implemented: Base, IBase { public void Process(int value) { // .. some code here.. } } I'm trying to write a loop similar to the following. foreach( Base b in CollectionOfImplemented ) { b.Process( // something will go here // ); } Trying this, it keeps calling Base.Process, instead of Implemented.Process; but the type in the collection is Implemented, not Base. Boxing it seems to work, but I was hoping to see if I could find a more intelligent approach to it, since the Collection will contain other types of objects that also inherit from Base.

    Read the article

  • ASP.NET MVC Model Binders, html id

    - by Stacey
    Using the Model Binders in ASP.NET MVC 2.0, you can do something like this... [DisplayName("User Name")] public string Name { get; set; } <%: Html.TextBoxFor( m => m.Name ) :%> and then in your HTML, you get a result like this.. <label for="UserName">User Name</label> <input type="text" id="UserName" name="UserName" /> That works fine, but I want to have better control over the HTML ID. Is there any way to do this through the model binding method?

    Read the article

  • Custom DDL Templates for Visual Studio 2010

    - by Stacey
    I was wondering if anyone knows of some good community distributed custom DDL templates for Entity Framework 4.0. The default DDL to SQL10 Works well enough, but we're looking to do some customization to the naming convention that it just isn't offering us. I'm not really finding many samples out there of people doing this, so I was hoping someone might know of a resource I'm overlooking (perhaps I am searching for it wrong, or misunderstanding how the whole process works) Specifically we're wanting to change up how it writes out fields from relationships. For instance, the default template puts in.. tablename_propertyendpoint_propertyname. We're wanting to find tune this to our naming scheme a little more. And none of us can quite figure out where in the .tt files it is doing this exact behavior.

    Read the article

  • Splitting a double in two, C#

    - by Stacey
    I'm attempting to use a double to represent a bit of a dual-value type in a database that must sometimes accept two values, and sometimes accept only one (int). So the field is a float in the database, and in my C# code, it is a double (since mapping it via EF makes it a double for some reason... ) So basically what I want to do .. let's say 2.5 is the value. I want to separate that out into 2, and 5. Is there any implicit way to go about this?

    Read the article

  • Unnecessary Redundancy with Tables.

    - by Stacey
    My items are listed as follows; This is just a summary of course. But I'm using a method shown for the "Detail" table to represent a type of 'inheritence', so to speak - since "Item" and "Downloadable" are going to be identical except that each will have a few additional fields relevant only to them. My question is in this design pattern. This sort of thing appears many, many times in our projects - is there a more intelligent way to handle it? I basically need to normalize the tables as much as possible. I'm extremely new to databases and so this is all very confusing to me. There are 5 items. Awards, Items, Purchases, Tokens, and Downloads. They are all very, very similar, except each has a few pieces of data relevant only to itself. I've tried to use a declaration field (like an enumerator 'Type' field) in conjunction with nullable columns, but I was told that is a bad approach. What I have done is take everything similar and place it in a single table, and then each type has its own table that references a column in the 'base' table. The problem occurs with relationships, or junctions. Linking all of these back to a customer. Each type takes around 2 additional tables to properly junction all of the data together- and as such, my database is growing very, very large. Is there a smarter practice for this kind of behavior? Item ID | GUID Name | varchar(64) Product ID | GUID Name | varchar(64) Store | GUID [ FK ] Details | GUID [FK] Downloadable ID | GUID Name | varchar(64) Url | nvarchar(2048) Details | GUID [FK] Details ID | GUID Price | decimal Description | text Peripherals [ JUNCTION ] ID | GUID Detail | GUID [FK] Store ID | GUID Addresses | GUID Addresses ID | GUID Name | nvarchar(64) State | int [FK] ZipCode | int Address | nvarchar(64) State ID | int Name | varchar(32)

    Read the article

  • EventHandlers saved to databases.

    - by Stacey
    In a database application (using Sql Server right now, in C#, with Entity Framework 4.0) I have a situation where I need to trigger events when some values change. For instance assume a class "Trackable". class Trackable { string Name { get; set; } int Positive { get; set; } int Negative { get; set; } int Total { get; set; } // event OnChanged } Trackable is represented in the database as follows; table Trackables Id | guid name | varchar(32) positive | int negative | int Total is of course, calculated at runtime. When a trackable event changes, I want to inspect its previous value, and then see what it is changing to, and be capable of reacting accordingly. However different trackables need to trigger different events (to avoid a huge, massive cascading switch/if block). If this were just only C# code it would be easy - but they have to be saved to the database. I can't divide up each different trackable into a different table/class, that would be silly - they are all identical, but the event raised is different based on how they are made. So I guess my question is, is there any way to store an event handler in a database such that.. Trackable t1 = new Trackable() { Name = "Trackable1" OnChange += TrackableChangedEventHandler(OnTrackable1Change) } Trackable t2 = new Trackable() { Name = "Trackable2", OnChange += TrackableChangedEventHandler(OnTrackable2Change) }

    Read the article

  • jQuery - add additional parameters on submit (NOT ajax)

    - by Stacey
    Using jQuery's 'submit' - is there a way to pass additional parameters to a form? I am NOT looking to do this with Ajax - this is normal, refresh-typical form submission. $('#submit').click(function () { $('#event').submit(function () { data: { form['attendees'] = $('#attendance').sortable('toArray').toString(); }); });

    Read the article

  • Installation stuck on "Installation Type" screen

    - by Andrew Latham
    I am trying to install Ubuntu 11.10 with Windows 7 from a CD. I am using an HP Pavilion dm4. I've never used Ubuntu (or any Linux) before. Everything goes alright until I get to the "Installation Type" screen. Instead of giving me options, it just has a blank menu, and all the buttons are disabled. When I click "Continue", it gives me an error saying that it can't find the root or something like that. The trial version works fine, but I can't actually install it. Everything on the trial version is really slow, presumably because everything is on the CD or the Windows partition. I did some research, but the only post I could find was http://ubuntuforums.org/showthread.php?t=1870478 Where the only advice is to format the entire drive, which I'm not willing to do. Any suggestions? I'm downloading 10.04 right now and I'm going to try with that instead. EDIT: 10.04 didn't work either. I got to the partitioning screen and got the same problem. I read some more forums, loaded up 11.10 trial from the disk, opened the Terminal and typed sudo apt-get remove dmraid and then y. Then I was actually able to see something on the "Installation type" page: "Erase disk and install Ubuntu" or "Something else". Which is weird, since Windows 7 should be installed. When I click Something Else, I get: /dev/sda /dev/sdb /dev/sdb1 (ntfs) (208 MB) (69 MB used) /dev/sdb2 (ntfs) (477542 MB) (unknown used) /dev/sdb3 (ntfs) (18085 MB) (16094 MB used) /dev/sdb4 (fat32) (4265 MB) (3084 MB used) I have no idea what any of this means. Also, my device for boot loader installation changed from /dev/sda to /dev/sda ATA SAMSUNG MZMPA032 (32.0 GB)

    Read the article

  • How to map network scanner

    - by Andrew Heath
    I have just bought a shiny new Canon MG6250 multifunction printer/scanner and connected it via LAN. Installing the printing side of things was a breeze, however, I cannot work out how to set up scanning. I installed the MG6200 series ScanGear MP driver from Canon's site but when I open GIMP or Simple Scan, they say there is no scanner detected. Using GIMP's 'update scanner list' button to search for the scanner does not find it. How do I tell Ubuntu, GIMP or Simple Scan to look on the network for the scanner? Is there another utility especially for this?

    Read the article

  • Practical Performance Monitoring and Tuning Event

    - by Andrew Kelly
      For any of you who may be interested or know of someone in the market for a performance Monitoring and Tuning class I have just the ticket for you. It’s a 3 day event that will be held in Atlanta Ga. on January 25th to the 27th 2011. For those of you that know me or have been to my sessions you realize I like to provide more than just classroom theory and like to teach real world and above all practical methodology when it comes to performance in SQL Server. This class covers all the essentials...(read more)

    Read the article

  • Implementing a wrapping wire (like the Worms Ninja Rope) in a 2D physics engine

    - by Andrew Russell
    I've been trying out some rope-physics recently, and I've found that the "standard" solution - making a rope from a series of objects strung together with springs or joints - is unsatisfying. Especially when rope swinging is relevant to gameplay. I don't really care about a rope's ability to wrap up or sag (this can be faked for visuals anyway). For gameplay, what is important is the ability for the rope to wrap around the environment and then subsequently unwrap. It doesn't even have to behave like rope - a "wire" made up of straight line segments would do. Here's an illustration: This is very similar to the "Ninja Rope" from the game Worms. Because I'm using a 2D physics engine - my environment is made up of 2D convex polygons. (Specifically I am using SAT in Farseer.) So my question is this: How would you implement the "wrapping" effect? It seems pretty obvious that the wire will be made up of a series of line segments that "split" and "join". And the final (active) segment of that line, where the moving object attaches, will be a fixed-length joint. But what is the maths / algorithm involved for determining when and where the active line segment needs to be split? And when it needs to be joined with the previous segment? (Previously this question also asked about doing this for a dynamic environment - I've decided to split that off into other questions.)

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >