Search Results

Search found 315 results on 13 pages for 'edward loper'.

Page 11/13 | < Previous Page | 7 8 9 10 11 12 13  | Next Page >

  • How to refer to items in Dictionary<string, string> by integer index?

    - by Edward Tanguay
    I made a Dictionary<string, string> collection so that I can quickly reference the items by their string identifier. But I now also need to access this collective by index counter (foreach won't work in my real example). What do I have to do to the collection below so that I can access its items via integer index as well? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestDict92929 { class Program { static void Main(string[] args) { Dictionary<string, string> events = new Dictionary<string, string>(); events.Add("first", "this is the first one"); events.Add("second", "this is the second one"); events.Add("third", "this is the third one"); string description = events["second"]; Console.WriteLine(description); string description = events[1]; //error Console.WriteLine(description); } } }

    Read the article

  • Strategies for when to use properties and when to use internal variables on internal classes?

    - by Edward Tanguay
    In almost all of my classes, I have a mixture of properties and internal class variables. I have always chosen one or the other by the rule "property if you need it externally, class variable if not". But there are many other issues which make me rethink this often, e.g.: at some point I want to use an internal variable from outside the class, so I have to refactor it into a property which makes me wonder why I don't just make all my internal variables properties in case I have to access them externally anyway, since most classes are internal classes anyway it aren't exposed on an API so it doesn't really matter if the internal variables are accessible from outside the class or not but then since C# doesn't allow you to instantiate e.g. List<string> property in the definition, then these properties have to be initialized in every possible constructor, so these variables I would rather have internal variables just to keep things cleaner in that they are all initialized in one place C# code reads more cleanly if constructor/method parameters are camel case and you assign them to pascal case properties instead of the ambiguity of seeing "templateIdCode" and having to look around to see if it is a local variable, method parameter or internal class variable, e.g. it is easier when you see "TemplateIdCode = templateIdCode" that this is a parameter being assigned to a class property. This would be an argument for always using only properties on internal classes. e.g.: public class TextFile { private string templateIdCode; private string absoluteTemplatePathAndFileName; private string absoluteOutputDirectory; private List<string> listItems = new List<string>(); public string Content { get; set; } public List<string> ReportItems { get; set; } public TextFile(string templateIdCode) { this.templateIdCode = templateIdCode; ReportItems = new List<string>(); Initialize(); } ... When creating internal (non-API) classes, what are your strategies in deciding if you should create an internal class variable or a property?

    Read the article

  • Why is a Silverlight application created from an exported template show a blank screen in the browse

    - by Edward Tanguay
    I created a silverlight app (without website) named TestApp, with one TextBox: <UserControl x:Class="TestApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot"> <TextBlock Text="this is a test"/> </Grid> </UserControl> I press F5 and see "this is a test" in my browser (firefox). I select File | Export Template | name it TestAppTemplate and save it. I create a new silverlight app based on the above template. The MainPage.xaml has the exact same XAML as above. I press F5 and see a blank screen in my browser. I look at the HTML source of both of these and they are identical. Everything I have compared in both projects is identical. What do I have to do so that a Silverlight application which is created from my exported template does not show a blank screen?

    Read the article

  • An efficient code to determine if a set is a subset of another set

    - by Edward
    I am looking for an efficient way to determine if a set is a subset of another set in Matlab or Mathematica. Example: Set A = [1 2 3 4] Set B = [4 3] Set C = [3 4 1] Set D = [4 3 2 1] The output should be: Set A Sets B and C belong to set A because A contains all of their elements, therefore, they can be deleted (the order of elements in a set doesn't matter). Set D has the same elements as set A and since set A precedes set D, I would like to simply keep set A and delete set D. So there are two essential rules: 1. Delete a set if it is a subset of another set 2. Delete a set if its elements are the same as those of a preceding set My Matlab code is not very efficient at doing this - it mostly consists of nested loops. Suggestions are very welcome! Additional explanation: the issue is that with a large number of sets there will be a very large number of pairwise comparisons.

    Read the article

  • What is the best way in Silerlight to make areas of a large graphic clickable?

    - by Edward Tanguay
    In a Silverlight application I have large images which have flow charts on them. I need to handle the clicks on specific hotspots of the image where the flow chart boxes are. Since the flow charts will always be different, the information of where the hotspots has to be dynamic, e.g. in a list of coordinates. I've found article like this one but don't need the detail of e.g. the outline of countries but just simple rectangle and circle areas. I've also found articles where they talk about overlaying an HTML image map over the silverlight application, but it has to be easier than this. What is the best way to handle clicks on specific areas of an image in silverlight?

    Read the article

  • Why would Visual Studio 2010 say it can't show a variable during debug?

    - by Edward Tanguay
    In Visual Studio 2010 sometimes when I want to get the value of a variable while debugging, it tells me that it "does not exist in this context" when it obviously does. I have found that if I use the variable, as in the screenshot below, then it is able to show it. Has anyone experienced this? Visual Studio 2008 never did this. How can I get Visual Studio 2010 to always show me variable values while debugging?

    Read the article

  • How to get Firefox to not continue to show "Transferring data from..." in browser status bar after a

    - by Edward Tanguay
    The following silverlight demo loads and displays a text file from a server. However, in Firefox (but not Explorer or Chrome) after you click the button and the text displays, the status bar continues to show "Transferring data from test.development..." which erroneously gives the user the belief that something is still loading. I've noticed that if you click on another Firefox tab and then back on the original one, the message goes away, so it seems to be just a Firefox bug that doesn't clear the status bar automatically. Is there a way to clear the status bar automatically in Firefox? or a way to explicitly tell it that the async loading is finished so it can clear the status bar itself? XAML: <UserControl x:Class="TestLoad1111.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <StackPanel Margin="10"> <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 0 0 10"> <Button Content="Load Text" Click="Button_LoadText_Click"/> </StackPanel> <TextBlock Text="{Binding Message}" /> </StackPanel> </UserControl> Code Behind: using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.ComponentModel; namespace TestLoad1111 { public partial class MainPage : UserControl, INotifyPropertyChanged { #region ViewModelProperty: Message private string _message; public string Message { get { return _message; } set { _message = value; OnPropertyChanged("Message"); } } #endregion public MainPage() { InitializeComponent(); DataContext = this; } private void Button_LoadText_Click(object sender, RoutedEventArgs e) { WebClient webClientTextLoader = new WebClient(); webClientTextLoader.DownloadStringAsync(new Uri("http://test.development:111/testdata/test.txt?" + Helpers.GetRandomizedSuffixToPreventCaching())); webClientTextLoader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClientTextLoader_DownloadStringCompleted); } void webClientTextLoader_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { Message = e.Result; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } public static class Helpers { private static Random random = new Random(); public static int GetRandomizedSuffixToPreventCaching() { return random.Next(10000, 99999); } } }

    Read the article

  • Why do firefox/chrome show a different page than IE8?

    - by Edward Tanguay
    When I look at this published Google Docs document, I see the latest version with Firefox and Chrome, but an older version with IE8. Also, screen-scraping it via PHP/Curl gives me an older version. I've tried CTRL-Refresh in IE8 but I can't get it to show me the newest version. No matter what headers I try to change in PHP/Curl, I can't get it to show me the newest version. What am I not understanding about browsers/headers/caching here? How can it be that different browsers show different contents of one page?

    Read the article

  • Why does this textbox binding example work in WPF but not in Silverlight?

    - by Edward Tanguay
    Why is it in the following silverlight application that when I: change the default text in the first textbox move the cursor to the second text box (i.e. take focus off first textbox) click the button that inside the button handler, it still has the old value "default text"? What do I have to do to get the binding to work in Silverlight? The same code works fine in WPF. XAML: <UserControl x:Class="TestUpdate123.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <StackPanel Margin="10" HorizontalAlignment="Left"> <TextBox Text="{Binding InputText}" Height="200" Width="600" Margin="0 0 0 10"/> <StackPanel HorizontalAlignment="Left"> <Button Content="Convert" Click="Button_Convert_Click" Margin="0 0 0 10"/> </StackPanel> <TextBox Height="200" Width="600" Margin="0 0 0 10"/> <TextBlock Text="{Binding OutputText}"/> </StackPanel> </UserControl> Code Behind: using System.Windows; using System.Windows.Controls; using System.ComponentModel; namespace TestUpdate123 { public partial class MainPage : UserControl, INotifyPropertyChanged { #region ViewModelProperty: InputText private string _inputText; public string InputText { get { return _inputText; } set { _inputText = value; OnPropertyChanged("InputText"); } } #endregion #region ViewModelProperty: OutputText private string _outputText; public string OutputText { get { return _outputText; } set { _outputText = value; OnPropertyChanged("OutputText"); } } #endregion public MainPage() { InitializeComponent(); DataContext = this; InputText = "default text"; } private void Button_Convert_Click(object sender, RoutedEventArgs e) { OutputText = InputText; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion } }

    Read the article

  • Why don't I have access to setReadDataOnly() or enableMemoryOptimization() in PHPExcel?

    - by Edward Tanguay
    I've downloaded PHPExcel 1.7.5 Production. I would like to use setReadDataOnly() and enableMemoryOptimization() as discussed in their forum here and in stackoverflow questions. However when I use them, I get a Call to undefined method error. Is there another version or some plugin or library that I have not installed? What do I have to do to access these methods? $objPHPExcel = PHPExcel_IOFactory::load("data/".$file_name); $objPHPExcel->setReadDataOnly(true); //Call to undefined method $objPHPExcel->enableMemoryOptimization(); //Call to undefined method

    Read the article

  • In MVVM are DataTemplates considered Views as UserControls are Views?

    - by Edward Tanguay
    In MVVM, every View has a ViewModel. A View I understand to be a Window, Page or UserControl to which you can attach a ViewModel from which the view gets its data. But a DataTemplate can also render a ViewModel's data. So I understand a DataTemplate to be another "View", but there seem to be differences, e.g. Windows, Pages, and UserControls can define their own .dlls, one type is bound with DataContect the other through attaching a template so that Windows, Pages, UserControls can can be attached to ViewModels dynamically by a ServiceLocator/Container, etc. How else are DataTemplates different than Windows/Pages/UserControls when it comes to rendering a ViewModel's data on the UI? And are there other types of "Views" other than these four?

    Read the article

  • Why would my Silverlight 4 Out-of-Browser application just display white?

    - by Edward Tanguay
    My Silverlight application works fine when running in a browser. But when I install it as an out-of-browser application, the Window frame comes up with an appropriate icon and title, but the content of the window is just white. It is in the start menu but when I close it and open again, it is still blank. I reproduced this on Windows 7 and Windows XP. What could be causing my silverlight application to show only white when running out-of-browser? Here are the settings I used:

    Read the article

  • Is there an optimal way to render images in cocoa? Im using setNeedsDisplay

    - by Edward An
    Currently, any time I manually move a UIImage (via handling the touchesMoved event) the last thing I call in that event is [self setNeedsDisplay], which effectively redraws the entire view. My images are also being animated, so every time a frame of animation changes, i have to call setNeedsDisplay. I find this to be horrific since I don't expect iphone/cocoa to be able to perform such frequent screen redraws very quickly. Is there an optimal, more efficient way that I could be doing this? Perhaps somehow telling cocoa to update only a particular region of the screen (the rect region of the image)?

    Read the article

  • How to get the height of an Image in Silverlight?

    - by Edward Tanguay
    I have this code in Silverlight: Image image = new Image(); BitmapImage bitmapImage= TheDatasourceManager.GetBitmapImage("blackPencil"); image.Source = bitmapImage; image.Stretch = Stretch.None; image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; image.Margin = new Thickness(88, 88, 0, 0); grid.Children.Add(image); Now I want to find out the height of the image. in WPF I can get it with image.Source.Height but this is not available in Silverlight bitmapImage.Height doesn't exist either when I debug and examine the image object, I eventually get to PixelHeight which has an accurate height, but I can't seem to access it I find image.ActualHeight but it is 0. How can I get the height of the image?

    Read the article

  • In Vim, what is the best way to select, delete, or comment out large portions of multi-screen text?

    - by Edward Tanguay
    Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when using it via putty/ssh where you cannot use the mouse? I can easily yank-to-the-end-of-line or yank-to-the-end-of-code-block but if the text extends over many screens, or has lots of blank lines in it, I feel like my hands are tied in Vim. Any solutions? And a related question: is there a way to somehow select 40 lines, and then comment them all out (with "#" or "//"), as is common in most IDEs?

    Read the article

  • Is there a more elegant way to act on the first and last items in a foreach enumeration than count++

    - by Edward Tanguay
    Is there a more elegant way to act on the first and last items when iterating through a foreach loop than incrementing a separate counter and checking it each time? For instance, the following code outputs: >>> [line1], [line2], [line3], [line4] <<< which requires knowing when you are acting on the first and last item. Is there a more elegant way to do this now in C# 3 / C# 4? It seems like I could use .Last() or .First() or something like that. using System; using System.Collections.Generic; using System.Text; namespace TestForNext29343 { class Program { static void Main(string[] args) { StringBuilder sb = new StringBuilder(); List<string> lines = new List<string> { "line1", "line2", "line3", "line4" }; int index = 0; foreach (var line in lines) { if (index == 0) sb.Append(">>> "); sb.Append("[" + line + "]"); if (index < lines.Count - 1) sb.Append(", "); else sb.Append(" <<<"); index++; } Console.WriteLine(sb.ToString()); Console.ReadLine(); } } }

    Read the article

  • Why does VerticalScrollBarVisibility not work in a style in Silverlight?

    - by Edward Tanguay
    VerticalScrollBarVisibility works when I define it inline like this: <UserControl x:Class="TestScrollBar.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> <UserControl.Resources> <Style TargetType="TextBox" x:Key="EditListContainerContentMultiLineTwoColumn"> <Setter Property="AcceptsReturn" Value="True"/> <Setter Property="Width" Value="400"/> <Setter Property="Height" Value="300"/> <Setter Property="IsReadOnly" Value="False"/> <Setter Property="Margin" Value="0 0 0 20"/> <Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="TextWrapping" Value="Wrap" /> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White" Margin="10"> <StackPanel HorizontalAlignment="Left"> <TextBox Text="this is a test" Style="{StaticResource EditListContainerContentMultiLineTwoColumn}" VerticalScrollBarVisibility="Auto" /> </StackPanel> </Grid> </UserControl> But when I put VerticalScrollBarVisibility in a style, it shows me a blank screen: <UserControl x:Class="TestScrollBar.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> <UserControl.Resources> <Style TargetType="TextBox" x:Key="EditListContainerContentMultiLineTwoColumn"> <Setter Property="VerticalScrollBarVisibility" Value="Auto"/> <Setter Property="AcceptsReturn" Value="True"/> <Setter Property="Width" Value="400"/> <Setter Property="Height" Value="300"/> <Setter Property="IsReadOnly" Value="False"/> <Setter Property="Margin" Value="0 0 0 20"/> <Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="TextWrapping" Value="Wrap" /> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White" Margin="10"> <StackPanel HorizontalAlignment="Left"> <TextBox Text="this is a test" Style="{StaticResource EditListContainerContentMultiLineTwoColumn}" /> </StackPanel> </Grid> </UserControl> In WPF it works works fine. How can I get VerticalScrollBarVisibility to work in a style?

    Read the article

  • How to SELECT the last 10 rows of an SQL table which has no ID field?

    - by Edward Tanguay
    I have an MySQL table with 25000 rows. This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything. However, since there is no ID column, I can't say: SELECT * FROM big_table ORDER BY id DESC What SQL statement would show me the last 10 rows of this table? The structure of the table is simply this: columns are: A, B, C, D, ..., AA, AB, AC, ... (like Excel) all fields are of type TEXT

    Read the article

  • How can I unattach an element from another element in the XAML tree?

    - by Edward Tanguay
    In my Silverlight application, I load all the images I need at application start and store them in a dictionary. Then as I need them I pick them out of the dictionary and attach them in XAML trees etc. However, I have the problem that if I attach an Image object to a Grid, then want to use that image again, it tells me: The image element is already a child of another element. How can I run through my dictionary and "detach all images from parent XAML elements"?

    Read the article

  • How to make a tooltip appear immediately in Silverlight?

    - by Edward Tanguay
    In WPF, I get a tooltip to appear immediately like this: TextBlock tb = new TextBlock(); tb.Text = name; ToolTip tt = new ToolTip(); tt.Content = "This is some info on " + name + "."; tb.ToolTip = tt; tt.Cursor = Cursors.Help; ToolTipService.SetInitialShowDelay(tb, 0); This makes the user experience better since if the user wants to look at the tooltips of five items on the page, he doesn't have to wait that long second for each one. But since Silverlight does not have SetInitialShowDelay, what is a workaround to make the tooltip appear immediately?

    Read the article

  • What is the best way to return two values from a method?

    - by Edward Tanguay
    When I have to write methods which return two values, I usually go about it as in the following code which returns a List<string>. Or if I have to return e.g. a id and string, then I return a List<object> and then pick them out with index number and recast the values. This recasting and referencing by index seems inelegant so I want to develop a new habit for methods that return two values. What is the best pattern for this? using System; using System.Collections.Generic; using System.Linq; namespace MultipleReturns { class Program { static void Main(string[] args) { string extension = "txt"; { List<string> entries = GetIdCodeAndFileName("first.txt", extension); Console.WriteLine("{0}, {1}", entries[0], entries[1]); } { List<string> entries = GetIdCodeAndFileName("first", extension); Console.WriteLine("{0}, {1}", entries[0], entries[1]); } Console.ReadLine(); } /// <summary> /// gets "first.txt", "txt" and returns "first", "first.txt" /// gets "first", "txt" and returns "first", "first.txt" /// it is assumed that extensions will always match /// </summary> /// <param name="line"></param> public static List<string> GetIdCodeAndFileName(string line, string extension) { if (line.Contains(".")) { List<string> parts = line.BreakIntoParts("."); List<string> returnItems = new List<string>(); returnItems.Add(parts[0]); returnItems.Add(line); return returnItems; } else { List<string> returnItems = new List<string>(); returnItems.Add(line); returnItems.Add(line + "." + extension); return returnItems; } } } public static class StringHelpers { public static List<string> BreakIntoParts(this string line, string separator) { if (String.IsNullOrEmpty(line)) return null; else { return line.Split(new string[] { separator }, StringSplitOptions.None).Select(p => p.Trim()).ToList(); } } } }

    Read the article

  • Why does a Silverlight application show a blank browser screen when created from exported template?

    - by Edward Tanguay
    I created a silverlight app (without website) named TestApp, with one TextBox: <UserControl x:Class="TestApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot"> <TextBlock Text="this is a test"/> </Grid> </UserControl> I press F5 and see "this is a test" in my browser (firefox). I select File | Export Template | name it TestAppTemplate and save it. I create a new silverlight app based on the above template. The MainPage.xaml has the exact same XAML as above. I press F5 and see a blank screen in my browser. I look at the HTML source of both of these and they are identical. Everything I have compared in both projects is identical. What do I have to do so that a Silverlight application which is created from my exported template does not show a blank screen? (creating a WPF application from an exported template like this works fine)

    Read the article

  • Is it possible to create nested classes in PHP as it is in C#?

    - by Edward Tanguay
    In C# you can have nested classes like this, which are useful if you have classes which do not have meaning outside the scope of one particular class, e.g. in a factory pattern: public abstract class BankAccount { private BankAccount() {} private sealed class SavingsAccount : BankAccount { ... } private sealed class CheckingAccount : BankAccount { ... } public BankAccount MakeSavingAccount() { ... } public BankAccount MakeCheckingAccount() { ... } } Is this possible in PHP? I've read that it was planned for PHP 5, then cancelled, then planned again, but can't find definitive info. Does anyone know how to create nested classes (classes within the scope of another class) as in the above C# example using PHP 5.3?

    Read the article

  • Is there a way to reduce the verbosity of using String.Format(...., p1, p2, p3)?

    - by Edward Tanguay
    I often use String.Format() because it makes the building of strings more readable and manageable. Is there anyway to reduce its syntactical verbosity, e.g. with an extension method, etc.? Logger.LogEntry(String.Format("text '{0}' registered", pair.IdCode)); public static void LogEntry(string message) { ... } e.g. I would like to use all my and other methods that receive a string the way I use Console.Write(), e.g.: Logger.LogEntry("text '{0}' registered", pair.IdCode);

    Read the article

< Previous Page | 7 8 9 10 11 12 13  | Next Page >