Search Results

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

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

  • Appropriate programming design questions.

    - by Edward
    I have a few questions on good programming design. I'm going to first describe the project I'm building so you are better equipped to help me out. I am coding a Remote Assistance Tool similar to TeamViewer, Microsoft Remote Desktop, CrossLoop. It will incorporate concepts like UDP networking (using Lidgren networking library), NAT traversal (since many computers are invisible behind routers nowadays), Mirror Drivers (using DFMirage's Mirror Driver (http://www.demoforge.com/dfmirage.htm) for realtime screen grabbing on the remote computer). That being said, this program has a concept of being a client-server architecture, but I made only one program with both the functionality of client and server. That way, when the user runs my program, they can switch between giving assistance and receiving assistance without having to download a separate client or server module. I have a Windows Form that allows the user to choose between giving assistance and receiving assistance. I have another Windows Form for a file explorer module. I have another Windows Form for a chat module. I have another Windows Form form for a registry editor module. I have another Windows Form for the live control module. So I've got a Form for each module, which raises the first question: 1. Should I process module-specific commands inside the code of the respective Windows Form? Meaning, let's say I get a command with some data that enumerates the remote user's files for a specific directory. Obviously, I would have to update this on the File Explorer Windows Form and add the entries to the ListView. Should I be processing this code inside the Windows Form though? Or should I be handling this in another class (although I have to eventually pass the data to the Form to draw, of course). Or is it like a hybrid in which I process most of the data in another class and pass the final result to the Form to draw? So I've got like 5-6 forms, one for each module. The user starts up my program, enters the remote machine's ID (not IP, ID, because we are registering with an intermediary server to enable NAT traversal), their password, and connects. Now let's suppose the connection is successful. Then the user is presented with a form with all the different modules. So he can open up a File Explorer, or he can mess with the Registry Editor, or he can choose to Chat with his buddy. So now the program is sort of idle, just waiting for the user to do something. If the user opens up Live Control, then the program will be spending most of it's time receiving packets from the remote machine and drawing them to the form to provide a 'live' view. 2. Second design question. A spin off question #1. How would I pass module-specific commands to their respective Windows Forms? What I mean is, I have a class like "NetworkHandler.cs" that checks for messages from the remote machine. NetworkHandler.cs is a static class globally accessible. So let's say I get a command that enumerates the remote user's files for a specific directory. How would I "give" that command to the File Explorer Form. I was thinking of making an OnCommandReceivedEvent inside NetworkHandler, and having each form register to that event. When the NetworkHandler received a command, it would raise the event, all forms would check it to see if it was relevant, and the appropriate form would take action. Is this an appropriate/the best solution available? 3. The networking library I'm using, Lidgren, provides two options for checking networking messages. One can either poll ReadMessage() to return null or a message, or one can use an AutoResetEvent OnMessageReceived (I'm guessing this is like an event). Which one is more appropriate?

    Read the article

  • What Regex can strip e.g. "note:" and "firstName: " from the left of a string?

    - by Edward Tanguay
    I need to strip the "label" off the front of strings, e.g. note: this is a note needs to return: note and this is a note I've produced the following code example but am having trouble with the regexes. What code do I need in the two ???????? areas below so that I get the desired results shown in the comments? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace TestRegex8822 { class Program { static void Main(string[] args) { List<string> lines = new List<string>(); lines.Add("note: this is a note"); lines.Add("test: just a test"); lines.Add("test:\t\t\tjust a test"); lines.Add("firstName: Jim"); //"firstName" IS a label because it does NOT contain a space lines.Add("She said this to him: follow me."); //this is NOT a label since there is a space before the colon lines.Add("description: this is the first description"); lines.Add("description:this is the second description"); //no space after colon lines.Add("this is a line with no label"); foreach (var line in lines) { Console.WriteLine(StringHelpers.GetLabelFromLine(line)); Console.WriteLine(StringHelpers.StripLabelFromLine(line)); Console.WriteLine("--"); //note //this is a note //-- //test //just a test //-- //test //just a test //-- //firstName //Jim //-- // //She said this to him: follow me. //-- //description //this is the first description //-- //description //this is the first description //-- // //this is a line with no label //-- } Console.ReadLine(); } } public static class StringHelpers { public static string GetLabelFromLine(this string line) { string label = line.GetMatch(@"^?:(\s)"); //??????????????? if (!label.IsNullOrEmpty()) return label; else return ""; } public static string StripLabelFromLine(this string line) { return ...//??????????????? } public static bool IsNullOrEmpty(this string line) { return String.IsNullOrEmpty(line); } } public static class RegexHelpers { public static string GetMatch(this string text, string regex) { Match match = Regex.Match(text, regex); if (match.Success) { string theMatch = match.Groups[0].Value; return theMatch; } else { return null; } } } }

    Read the article

  • How to get a TextBlock to right-align?

    - by Edward Tanguay
    How do I get the TextBlock in my status bar below to align to the right? I've told it to: HorizontalAlignment="Right" TextAlignment="Right" but the text is still sitting unobediently on the left. What else do I have to say? <Window x:Class="TestEvents124.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" MaxWidth="700" Width="700" > <DockPanel HorizontalAlignment="Stretch" Margin="0,0,0,0" Width="Auto"> <StatusBar Width="Auto" Height="25" Background="#888" DockPanel.Dock="Bottom" HorizontalAlignment="Stretch"> <TextBlock Width="Auto" Height="Auto" Foreground="#fff" Text="This is the footer." HorizontalAlignment="Right" TextAlignment="Right" /> </StatusBar> <GroupBox DockPanel.Dock="Top" Height="Auto" Header="Main Content"> <WrapPanel Width="Auto" Height="Auto"> <TextBlock Width="Auto" Height="Auto" TextWrapping="Wrap" Padding="10"> This is an example of the content, it will be swapped out here. </TextBlock> </WrapPanel> </GroupBox> </DockPanel> </Window>

    Read the article

  • What is the best euphemism for a non-developer?

    - by Edward Tanguay
    I'm writing a description for a piece of software that targets the user who is "not technically minded", i.e. a person who uses "browser/office/email" and has a low tolerance for anything technical, he just "wants it to work" without being involved in any of the technical details. What is the best non-disparaging term you have seen to describe this kind of user? non-technical user low-tech user office user normal user technically challenged user non-developer computer joe Surely there is some official, politically-correct retronym for this kind of user that the press and software marketing use.

    Read the article

  • How do I make sure no handlers are attached to an event?

    - by Edward Tanguay
    I am adding an event handler like this: theImage.MouseMove += new MouseEventHandler(theImage_MouseMove); but in my application, this code gets run every time the page is shown, so I want to attach the event handler only once, but how can I tell if a handler has been set yet or not, something like this: if(theImage.MouseMove == null) //error theImage.MouseMove += new MouseEventHandler(theImage_MouseMove);

    Read the article

  • Can you dynamically resize a java.util.concurrent.ThreadPoolExecutor while it still has tasks waitin

    - by Edward Shtern
    I'm working with a java.util.concurrent.ThreadPoolExecutor to process a number of items in parallel. Although the threading itself works fine, at times we've run into other resource constraints due to actions happening in the threads, which made us want to dial down the number of Threads in the pool. I'd like to know if there's a way to dial down the number of the threads while the threads area actually working. I know that you can call setMaximumPoolSize() and/or setCorePoolSize(), but these only resize the pool once threads become idle, but they don't become idle until there are no tasks waiting in the queue.

    Read the article

  • How to enable a two-finger drag on a mac in Silverlight?

    - by Edward Tanguay
    In a Silverlight 4 application I have a ScrollViewer which I enable the user to scroll with the mouse wheel by using SetIsMouseWheelScrollingEnabled(): <ScrollViewer x:Name="CodeBoxScrollViewerModelSingular" tk:DockPanel.Dock="Left" Style="{StaticResource ScrollViewerCodeBoxStyle}"> <TextBox Text="{Binding SingularModelFileContent}" Style="{StaticResource TextBoxCodeBoxStyle}"/> </ScrollViewer> CodeBoxScrollViewerModelSingular.SetIsMouseWheelScrollingEnabled(true); However, someone tested it on a Mac and said: The only problem I noticed on a quick test was that I couldn't scroll down by using a two-finger drag, which has been standard UI behavior on the Mac for several years now. Is there any way to enable a "two-finger drag" on the Mac as you can enable mouse wheel scrolling?

    Read the article

  • How to show loading spinner in jQuery?

    - by Edward Tanguay
    In Prototype I can show a "loading..." image with this code: var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); function showLoad () { ... } In jQuery, I can load a server page into an element with this: $('#message').load('index.php?pg=ajaxFlashcard'); but how do I attach a loading spinner to this command as I did in Prototype?

    Read the article

  • How to automatically read in calculated values with PHPExcel?

    - by Edward Tanguay
    I have the following Excel file: I read it in by looping over every cell and getting the value with getCell(...)->getValue(): $highestColumnAsLetters = $this->objPHPExcel->setActiveSheetIndex(0)->getHighestColumn(); //e.g. 'AK' $highestRowNumber = $this->objPHPExcel->setActiveSheetIndex(0)->getHighestRow(); $highestColumnAsLetters++; for ($row = 1; $row < $highestRowNumber + 1; $row++) { $dataset = array(); for ($columnAsLetters = 'A'; $columnAsLetters != $highestColumnAsLetters; $columnAsLetters++) { $dataset[] = $this->objPHPExcel->setActiveSheetIndex(0)->getCell($columnAsLetters.$row)->getValue(); if ($row == 1) { $this->column_names[] = $columnAsLetters; } } $this->datasets[] = $dataset; } However, although it reads in the data fine, it reads in the calculations literally: I understand from discussions like this one that I can use getCalculatedValue() for calculated cells. The problem is that in the Excel sheets I am importing, I do not know beforehand which cells are calculated and which are not. Is there a way for me to read in the value of a cell in a way that automatically gets the value if it has a simple value and gets the result of the calculation if it is a calculation?

    Read the article

  • What is the easiest way to remove the Silverlight TextBox mouse hover border?

    - by Edward Tanguay
    I want to display text in a Silverlight application so that the user can copy and paste it elsewhere (as one is used to doing on an HTML web site). If I use TextBlock, then the user cannot cut and paste. Therefore I use TextBox, but it has a default border on it. I can remove the border with BorderThickness="0" like this: <TextBox Grid.Column="1" BorderThickness="0" Text="{Binding ViewModelBindingStringsBlockHelp}"/> which works great: However, when the user hovers over the text box to select the text, another border appears: I've found purported solutions but they seem to require pages of XAML. I'm looking for a simple solution like this: HoverBorderThickness="0" What is an easy way to hide the hover border on a Silverlight TextBox?

    Read the article

  • How can I get jquery to toggle-fade a flashcard div open and closed on click?

    - by Edward Tanguay
    What do I have to change to the code below in order for the user to click on a flashcard header to open and close the flashcard answer? I couldn't get toggle() to work with fadein/fadeout the version below doesn't respond to the click code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("jquery", "1.4.1"); google.setOnLoadCallback(function() { $("div > div.question").click(function() { if($(this).next().is(":hidden") { $(this).next().fadeIn("slow"); } else { $(this).next().fadeOut("slow"); } }); }); </script> <style> div.flashcard { margin: 0 10px 10px 0; } div.flashcard div.question { background-color:#ddd; width: 400px; padding: 5px; cursor: hand; cursor: pointer; } div.flashcard div.answer { background-color:#eee; width: 400px; padding: 5px; display: none; } </style> </head> <body> <div id="1" class="flashcard"> <div class="question">Who was Wagner?</div> <div class="answer">German composer, conductor, theatre director and essayist, primarily known for his operas (or "music dramas", as they were later called). Unlike most other opera composers, Wagner wrote both the music and libretto for every one of his works.</div> </div> <div id="2" class="flashcard"> <div class="question">Who was Thalberg?</div> <div class="answer">a composer and one of the most distinguished virtuoso pianists of the 19th century.</div> </div> </body> </html>

    Read the article

  • What do I have to change in my PHP/CURL code to retrieve data from a https:// URL?

    - by Edward Tanguay
    I have a PHP file using CURL that accepts a Google Doc URL as a parameter, then returns the plain text of the Google Doc. It worked well until recently when apparently a redirect was added so that the http:// address redirects to the equivalent https:// address, as in this example: http://docs.google.com/View?id=dc7gj86r_20dn2csqg3 So I changed my code to access the https:// address, but it just returns blank. What do I have to change my CURL code so that I can get the HTML text from the https:// address? $url = filter_input(INPUT_GET, 'url',FILTER_SANITIZE_STRING); $validUrlPrefixes[] = "https://docs.google.com"; if(beginsWithOneOfThese($url, $validUrlPrefixes)) { $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie"); curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie"); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_VERBOSE, 0); $rawData = curl_exec($ch); $rawData = cleanText($rawData); if(beginsWith($url, "https://docs.google.com")) { echo qstr::convertGoogleDocContentToText($rawData); die; } echo $rawData; die;

    Read the article

  • crashing out in a while loop python

    - by Edward
    How to solve this error? i want to pass the values from get_robotxya() and get_ballxya() and use it in a loop but it seems that it will crash after awhile how do i fix this? i want to get the values whithout it crashing out of the while loop import socket import os,sys import time from threading import Thread HOST = '59.191.193.59' PORT = 5555 COORDINATES = [] def connect(): globals()['client_socket'] = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect((HOST,PORT)) def update_coordinates(): connect() screen_width = 0 screen_height = 0 while True: try: client_socket.send("loc\n") data = client_socket.recv(8192) except: connect(); continue; globals()['COORDINATES'] = data.split() if(not(COORDINATES[-1] == "eom" and COORDINATES[0] == "start")): continue if (screen_width != int(COORDINATES[2])): screen_width = int(COORDINATES[2]) screen_height = int(COORDINATES[3]) return def get_ballxy(): update_coordinates() ballx = int(COORDINATES[8]) bally = int(COORDINATES[9]) return ballx,bally def get_robotxya(): update_coordinates() robotx = int(COORDINATES[12]) roboty = int(COORDINATES[13]) angle = int(COORDINATES[14]) return robotx,roboty,angle def print_ballxy(bx,by): print bx print by def print_robotxya(rx,ry,a): print rx print ry print a def activate(): bx,by = get_ballxy() rx,ry,a = get_robotxya() print_ballxy(bx,by) print_robotxya(rx,ry,a) Thread(target=update_coordinates).start() while True: activate() this is the error i get:

    Read the article

  • How do I animate a single ChartSeriesItem in a Flex 3 Chart?

    - by Edward Stembler
    Here's my setup... I have a ColumnChart above a DataGrid. When the user clicks on an individual column in the chart, I programmatically select the corresponding cell in the DataGrid. Conversely, if a user clicks a cell on the DataGrid, I select the corresponding column in the Chart and change it's color to haloBlue. This work well, however if possible I’d like to make the column stand out more. Is there a way to animate an individual column and not the entire series? For example, I might like to make the column zoom or expand out and back to it’s original size once selected. Or, if this is not possible, can a stroke be added to only the selected column and not the entire series? Anyone have any ideas? Thanks!

    Read the article

  • How to get the coordinates of an image mouse click in the event handler?

    - by Edward Tanguay
    In the following WPF app, I have an Image in a ContentControl. When the user clicks on the image, how can I get the x/y coordinates of where the mouse clicked on the image? XAML: <Window x:Class="TestClick828374.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <StackPanel Margin="10"> <ContentControl Content="{Binding TheImage}" MouseDown="ContentControl_MouseDown"/> </StackPanel> </Window> Code-Behind: using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.ComponentModel; namespace TestClick828374 { public partial class Window1 : Window, INotifyPropertyChanged { #region ViewModelProperty: TheImage private Image _theImage; public Image TheImage { get { return _theImage; } set { _theImage = value; OnPropertyChanged("TheImage"); } } #endregion public Window1() { InitializeComponent(); DataContext = this; TheImage = new Image(); TheImage.Source = new BitmapImage(new Uri(@"c:\test\rectangle.png")); TheImage.Stretch = Stretch.None; TheImage.HorizontalAlignment = HorizontalAlignment.Left; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion private void ContentControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { //how to get the coordinates of the mouse click here on the image? } } }

    Read the article

  • Code runs 6 times slower with 2 threads than with 1

    - by Edward Bird
    So I have written some code to experiment with threads and do some testing. The code should create some numbers and then find the mean of those numbers. I think it is just easier to show you what I have so far. I was expecting with two threads that the code would run about 2 times as fast. Measuring it with a stopwatch I think it runs about 6 times slower! void findmean(std::vector<double>*, std::size_t, std::size_t, double*); int main(int argn, char** argv) { // Program entry point std::cout << "Generating data..." << std::endl; // Create a vector containing many variables std::vector<double> data; for(uint32_t i = 1; i <= 1024 * 1024 * 128; i ++) data.push_back(i); // Calculate mean using 1 core double mean = 0; std::cout << "Calculating mean, 1 Thread..." << std::endl; findmean(&data, 0, data.size(), &mean); mean /= (double)data.size(); // Print result std::cout << " Mean=" << mean << std::endl; // Repeat, using two threads std::vector<std::thread> thread; std::vector<double> result; result.push_back(0.0); result.push_back(0.0); std::cout << "Calculating mean, 2 Threads..." << std::endl; // Run threads uint32_t halfsize = data.size() / 2; uint32_t A = 0; uint32_t B, C, D; // Split the data into two blocks if(data.size() % 2 == 0) { B = C = D = halfsize; } else if(data.size() % 2 == 1) { B = C = halfsize; D = hsz + 1; } // Run with two threads thread.push_back(std::thread(findmean, &data, A, B, &(result[0]))); thread.push_back(std::thread(findmean, &data, C, D , &(result[1]))); // Join threads thread[0].join(); thread[1].join(); // Calculate result mean = result[0] + result[1]; mean /= (double)data.size(); // Print result std::cout << " Mean=" << mean << std::endl; // Return return EXIT_SUCCESS; } void findmean(std::vector<double>* datavec, std::size_t start, std::size_t length, double* result) { for(uint32_t i = 0; i < length; i ++) { *result += (*datavec).at(start + i); } } I don't think this code is exactly wonderful, if you could suggest ways of improving it then I would be grateful for that also.

    Read the article

  • What is the fastest way to trim blank lines from beginning and end of array?

    - by Edward Tanguay
    This script: <?php $lines[] = ''; $lines[] = 'first line '; $lines[] = 'second line '; $lines[] = ''; $lines[] = 'fourth line'; $lines[] = ''; $lines[] = ''; $lineCount = 1; foreach($lines as $line) { echo $lineCount . ': [' . trim($line) . ']<br/>'; $lineCount++; } ?> produces this output: 1: [] 2: [first line] 3: [second line] 4: [] 5: [fourth line] 6: [] 7: [] What is the fastest, most efficient way to change the above script so that it also deletes the preceding and trailing blank entries but not the interior blank entries so that it outputs this: 1: [first line] 2: [second line] 3: [] 4: [fourth line] I could use the foreach loop but I imagine there is a way with array_filter or something similar which is much more efficient.

    Read the article

  • How to handle not-enough-isolatedstorage issue deep in data loader?

    - by Edward Tanguay
    I have a silverlight application which loads data from many external data sources into IsolatedStorage, and while loading any of these sources if it does not have enough IsolatedStorage, it ends up in a catch statement. At that point in that catch statement I would like to ask the user to click a button to approve silverlight to increase the IsolatedStorage capacity. The problem is, although I have a "SwitchPage()" method with which I display a page, if I access it at this point it is too deep in the loading process and the application always goes into an endless loop, hangs and crashes. I need a way to branch out of the application completely somehow to an independent UserControl which has a button and code behind which does the increase logic. What is a solution for an application to be able to branch out of a loading process catch statement like this, display a user control which has a button to ask the user to increase the IsolatedStorage? public static void SaveBitmapImageToIsolatedStorageFile(OpenReadCompletedEventArgs e, string fileName) { try { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf)) { Int64 imgLen = (Int64)e.Result.Length; byte[] b = new byte[imgLen]; e.Result.Read(b, 0, b.Length); isfs.Write(b, 0, b.Length); isfs.Flush(); isfs.Close(); isf.Dispose(); } } } catch (IsolatedStorageException) { //handle: present user with button to increase isolated storage } catch (TargetInvocationException) { //handle: not saved } }

    Read the article

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