Search Results

Search found 4334 results on 174 pages for 'sender'.

Page 49/174 | < Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >

  • Execute function without sending 'self' to it

    - by Sergey
    Is that possible to define a function without referencing to self this way? def myfunc(var_a,var_b) But so that it could also get sender data, like if I defined it like this: def myfunc(self, var_a,var_b) That self is always the same so it looks a little redundant here always to run a function this way: myfunc(self,'data_a','data_b'). Then I would like to get its data in the function like this sender.fields. UPDATE: Here is some code to understand better what I mean. The class below is used to show a page based on Jinja2 templates engine for users to sign up. class SignupHandler(webapp.RequestHandler): def get(self, *args, **kwargs): utils.render_template(self, 'signup.html') And this code below is a render_template that I created as wrapper to Jinja2 functions to use it more conveniently in my project: def render_template(response, template_name, vars=dict(), is_string=False): template_dirs = [os.path.join(root(), 'templates')] logging.info(template_dirs[0]) env = Environment(loader=FileSystemLoader(template_dirs)) try: template = env.get_template(template_name) except TemplateNotFound: raise TemplateNotFound(template_name) content = template.render(vars) if is_string: return content else: response.response.out.write(content) As I use this function render_template very often in my project and usually the same way, just with different template files, I wondered if there was a way to get rid of having to call it like I do it now, with self as the first argument but still having access to that object.

    Read the article

  • Chrome not sending POST requests on localhost, Firefox works fine

    - by AP257
    I have copied the simple Django forms example exactly, running on localhost. The basic contact form example should submit a POST request when you click the Submit button. I'm running Chrome on Mac Snow Leopard, and whenever I submit the form, the page simply reloads with an empty form: I can see from the runserver output that it's not sending a POST - instead it's sending a GET request. If I open the same page in Firefox on Mac Snow Leopard, and submit the form, I can see it's sending a POST request (as it should be). Looking at the source in Chrome, the form definitely says method="post". <form action="/contact/" method="post"> <p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" /></p> <p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></p> <p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" /></p> <p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p> <input type="submit" value="Submit" /> </form> External sites with POST forms seem to work OK in Chrome. In addition, if I fill the form in incorrectly, in Chrome the page just reloads, with a GET request, as before; in Firefox the form gets validated, as it should. I've tried with other POST forms on localhost and got the same result. I know Chrome for Mac has its quirks, but what on earth is going on?

    Read the article

  • Are there pitfalls to using static class/event as an application message bus

    - by Doug Clutter
    I have a static generic class that helps me move events around with very little overhead: public static class MessageBus<T> where T : EventArgs { public static event EventHandler<T> MessageReceived; public static void SendMessage(object sender, T message) { if (MessageReceived != null) MessageReceived(sender, message); } } To create a system-wide message bus, I simply need to define an EventArgs class to pass around any arbitrary bits of information: class MyEventArgs : EventArgs { public string Message { get; set; } } Anywhere I'm interested in this event, I just wire up a handler: MessageBus<MyEventArgs>.MessageReceived += (s,e) => DoSomething(); Likewise, triggering the event is just as easy: MessageBus<MyEventArgs>.SendMessage(this, new MyEventArgs() {Message="hi mom"}); Using MessageBus and a custom EventArgs class lets me have an application wide message sink for a specific type of message. This comes in handy when you have several forms that, for example, display customer information and maybe a couple forms that update that information. None of the forms know about each other and none of them need to be wired to a static "super class". I have a couple questions: fxCop complains about using static methods with generics, but this is exactly what I'm after here. I want there to be exactly one MessageBus for each type of message handled. Using a static with a generic saves me from writing all the code that would maintain the list of MessageBus objects. Are the listening objects being kept "alive" via the MessageReceived event? For instance, perhaps I have this code in a Form.Load event: MessageBus<CustomerChangedEventArgs>.MessageReceived += (s,e) => DoReload(); When the Form is Closed, is the Form being retained in memory because MessageReceived has a reference to its DoReload method? Should I be removing the reference when the form closes: MessageBus<CustomerChangedEventArgs>.MessageReceived -= (s,e) => DoReload();

    Read the article

  • how to edit a text message ( sms ) as it arrives in windows mobile 6 using managed code

    - by x86shadow
    I want to make an application to be installed on two pocket PCs and send Encrypted text messages and receive and decrypt them on the other device. I already made an application that gets special text messages ( starting with !farenc! ) and I know how to Encrypt/Decrypt the messages as well but I don't know how to edit a text message as it's arrive ( for decryption ). please help. thanks in advance and sorry for my bad English using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.WindowsMobile; using Microsoft.WindowsMobile.PocketOutlook; using Microsoft.WindowsMobile.PocketOutlook.MessageInterception; namespace SMSDECRYPT { public partial class Form1 : Form { MessageInterceptor _SMSCatcher = new MessageInterceptor(InterceptionAction.Notify, true); MessageCondition _SMSFilter = new MessageCondition(); public Form1() { InitializeComponent(); _SMSFilter.Property = MessageProperty.Body; _SMSFilter.ComparisonType = MessagePropertyComparisonType.StartsWith; _SMSFilter.CaseSensitive = true; _SMSFilter.ComparisonValue = "!farenc!"; _SMSCatcher.MessageCondition = _SMSFilter; _SMSCatcher.MessageReceived += new MessageInterceptorEventHandler(_SMSCatcher_MessageReceived); } private void Form1_Load(object sender, EventArgs e) { //... } void _SMSCatcher_MessageReceived(object sender, MessageInterceptorEventArgs e) { SmsMessage mySMS = (SmsMessage)e.Message; string sms = mySMS.Body.ToString(); sms = sms.Substring(8); //Decryption //... //Update the received message and replace it with the decrypted text //!!!HELP!!! } } }

    Read the article

  • Very strange Application.ThreadException behaviour.

    - by Brann
    I'm using the Application.ThreadException event to handle and log unexpected exceptions in my winforms application. Now, somewhere in my application, I've got the following code (or rather something equivalent, but this dummy code is enough to reproduce my issue) : try { throw new NullReferenceException("test"); } catch (Exception ex) { throw new Exception("test2", ex); } I'm clearly expecting my Application_ThreadException handler to be passed the "test2" exception, but this is not always the case. Typically, if another thread marshals my code to the UI, my handler receives the "test" exception, exactly as if I hadn't caught "test" at all. Here is a short sample reproducing this behavior. I have omitted the designer's code. static class Program { [STAThread] static void Main() { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { Console.WriteLine(e.Exception.Message); } } public partial class Form1 : Form { public Form1() { InitializeComponent(); button1.Click+=new EventHandler(button1_Click); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThrowEx)); t.Start(); } private void button1_Click(object sender, EventArgs e) { try { throw new NullReferenceException("test"); } catch (Exception ex) { throw new Exception("test2", ex); } } void ThrowEx() { this.BeginInvoke(new EventHandler(button1_Click)); } } The output of this program on my computer is : test ... here I click button1 test2 I've reproduced this on .net 2.0,3.5 and 4.0. Does someone have a logical explanation ?

    Read the article

  • GZipStream in an WebHttpResponse producing no data

    - by Pierre 303
    I want to compress my HTTP Responses for client that supports it. Here is the code used to send a standard response: IHttpClientContext context = (IHttpClientContext)sender; IHttpRequest request = e.Request; string responseBody = "This is some random text"; IHttpResponse response = request.CreateResponse(context); using (StreamWriter writer = new StreamWriter(response.Body)) { writer.WriteLine(responseBody); writer.Flush(); response.Send(); } The code above works fine. Now I added gzip support below. When I test it with a browser that supports gzip or a custom method, it returns an empty string. I'm sure I'm missing something simple, but I just can't find it... IHttpClientContext context = (IHttpClientContext)sender; IHttpRequest request = e.Request; string acceptEncoding = request.Headers["Accept-Encoding"]; string responseBody = "This is some random text"; IHttpResponse response = request.CreateResponse(context); if (acceptEncoding != null && acceptEncoding.Contains("gzip")) { byte[] bytes = ASCIIEncoding.ASCII.GetBytes(responseBody); response.AddHeader("Content-Encoding", "gzip"); using (GZipStream writer = new GZipStream(response.Body, CompressionMode.Compress)) { writer.Write(bytes, 0, bytes.Length); writer.Flush(); response.Send(); } } else { using (StreamWriter writer = new StreamWriter(response.Body)) { writer.WriteLine(responseBody); writer.Flush(); response.Send(); } }

    Read the article

  • how to make the printer window appear using vb.net 2010

    - by Jeline Esase
    hi I have this code that will send my panel into a printer but the problem is it doesent let me choose which printer I will use any idea on how can I make the printer window appear? thanks Public Class Form1 Dim img As Bitmap Dim WithEvents pd As PrintDocument 'Returns the Form as a bitmap Function CaptureForm1() As Bitmap Dim g1 As Graphics = Me.CreateGraphics() Dim MyImage = New Bitmap(Me.ClientRectangle.Width, (Me.ClientRectangle.Height), g1) Dim g2 As Graphics = Graphics.FromImage(MyImage) Dim dc1 As IntPtr = g1.GetHdc() Dim dc2 As IntPtr = g2.GetHdc() BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), dc1, 0, 0, 13369376) g1.ReleaseHdc(dc1) g2.ReleaseHdc(dc2) 'saves image to c drive just, u can comment it also 'MyImage.Save("c:\abc.bmp") Return MyImage End Function <DllImport("gdi32.DLL", EntryPoint:="BitBlt", _ SetLastError:=True, CharSet:=CharSet.Unicode, _ ExactSpelling:=True, _ CallingConvention:=CallingConvention.StdCall)> _ Private Shared Function BitBlt(ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As System.Int32) As Boolean ' Leave function empty - DLLImport attribute forwards calls to MoveFile to ' MoveFileW in KERNEL32.DLL. End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click img = CaptureForm1() pd = New PrintDocument pd.Print() End Sub 'this method will be called each time when pd.printpage event occurs Sub pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles pd.PrintPage Dim x As Integer = e.MarginBounds.X Dim y As Integer = e.MarginBounds.Y e.Graphics.DrawImage(img, x, y) e.HasMorePages = False End Sub End Class

    Read the article

  • How can I make NSUndoManager's undo/redo action names work properly?

    - by Gabe
    I'm learning Cocoa, and I've gotten undo to work without much trouble. But the setActionName: method is puzzling me. Here's a simple example: a toy app whose windows contain a single text label and two buttons. Press the On button and the label reads 'On'. Press the Off button and the label changes to read 'Off'. Here are the two relevant methods (the only code I wrote for the app): -(IBAction) turnOnLabel:(id)sender { [[self undoManager] registerUndoWithTarget:self selector:@selector(turnOffLabel:) object:self]; [[self undoManager] setActionName:@"Turn On Label"]; [theLabel setStringValue:@"On"]; } -(IBAction) turnOffLabel:(id)sender { [[self undoManager] registerUndoWithTarget:self selector:@selector(turnOnLabel:) object:self]; [[self undoManager] setActionName:@"Turn Off Label"]; [theLabel setStringValue:@"Off"]; } Here's what I expect: I click the On button The label changes to say 'On' In the Edit menu is the item 'Undo Turn On Label' I click that menu item The label changes to say 'Off' In the Edit menu is the item 'Redo Turn On Label' In fact, all these things work as I expect apart from the last one. The item in the Edit menu reads 'Redo Turn Off Label', not 'Redo Turn On Label'. (When I click that menu item, the label does turn to On, as I'd expect, but this makes the menu item's name even more of a mystery. What am i misunderstanding, and how can I get these menu items to display the way I want them to?

    Read the article

  • Hiding a Bar button item in the view

    - by devb0yax
    How can you able to hide the (done) bar button item in a view? Basically, I have a view controller added with navigation bar (in IB) then, I also added a bar button item into the nav bar. I just want initially the (done) bar button item is hidden.. when input is in the text view the (done) button is already visible. Any idea on this implementation on a view controller? Here's my sample code: @interface MyTextViewViewController : UIViewController <UITextViewDelegate> { UITextView *m_textView; UIBarButtonItem *doneBarButtonItem; } @property(nonatomic,retain) IBOutlet UITextView *m_textView; @property(nonatomic,retain) IBOutlet UIBarButtonItem *doneBarButtonItem; - (IBAction)saveAction:(id)sender; .m file: - (void)viewDidLoad { [super viewDidLoad]; doneBarButtonItem.hidden = YES; --> compile error!!! } - (void)textViewDidBeginEditing:(UITextView *)textView { doneBarButtonItem.hidden = NO; --> compile error!!! } - (IBAction)saveAction:(id)sender { doneBarButtonItem.hidden = YES; --> compile error!!! ... }

    Read the article

  • Diffrernce between BackgroundWorker.ReportProgress() and Control.Invoke()

    - by ohadsc
    What is the difference between options 1 and 2 in the following? private void BGW_DoWork(object sender, DoWorkEventArgs e) { for (int i=1; i<=100; i++) { string txt = i.ToString(); if (Test_Check.Checked) //OPTION 1 Test_BackgroundWorker.ReportProgress(i, txt); else //OPTION 2 this.Invoke((Action<int, string>)UpdateGUI, new object[] {i, txt}); } } private void BGW_ProgressChanged(object sender, ProgressChangedEventArgs e) { UpdateGUI(e.ProgressPercentage, (string)e.UserState); } private void UpdateGUI(int percent, string txt) { Test_ProgressBar.Value = percent; Test_RichTextBox.AppendText(txt + Environment.NewLine); } Looking at reflector, the Control.Invoke() appears to use: this.FindMarshalingControl().MarshaledInvoke(this, method, args, 1); whereas BackgroundWorker.Invoke() appears to use: this.asyncOperation.Post(this.progressReporter, args); (I'm just guessing these are the relevant function calls.) If I understand correctly, BGW Posts to the WinForms window its progress report request, whereas Control.Invoke uses a CLR mechanism to invoke on the right thread. Am I close? And if so, what are the repercussions of using either ? Thanks

    Read the article

  • LoginControl not working correctly with Firefox, requires double login attempt.

    - by CmdrTallen
    Any idea why LoginControl requires users authenticate twice with FireFox but works correctly (once) with IE? I am using a custom MembershipProvider and RoleProvider, if that matters. Authentication portion of my web.config; <authentication mode="Forms"> <forms timeout="50000000" protection="All" requireSSL="false" slidingExpiration="true" cookieless="AutoDetect" domain="" enableCrossAppRedirects="true"> <credentials passwordFormat="SHA1" /> </forms> </authentication> Membership section; <membership defaultProvider="CustomMembershipProvider"> <providers> <add name="CustomMembershipProvider" type="CustomCrateMembershipProvider" connectionString="" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> </providers> </membership> <roleManager defaultProvider="CustomRoleProvider" enabled="true"> <providers> <add name="CustomRoleProvider" type="CustomRoleProvider"/> </providers> </roleManager> Only code behind related to login; protected void OnLoggedIn(object sender, EventArgs e) { } protected void OnLoggingOut(object sender, EventArgs e) { }

    Read the article

  • ASP.NET page with base class with dynamic master page not firing events

    - by Kangkan
    Hi guys! I am feeling that I have terribly wrong somewhere. I was working on a small asp.net app. I have some dynamic themes in the \theme folder and have implemented a page base class to load the master page on the fly. The master is having the ContentPlaceHolder like: <asp:ContentPlaceHolder ID="cphBody" runat="server" /> Now I am adding pages that are derived from my base class and added the form elements. I know, Visual Studio has problem showing the page in the design mode. I have a dropdown box and wish to add the event of onselectedindexchange. But it is not working. the page is like this: <%@ Page Language="C#" AutoEventWireup="true" Inherits="trigon.web.Pages.MIS.JobStatus" Title="Job Status" AspCompat="true" CodeBehind="JobStatus.aspx.cs" %> <asp:Content ID="Content1" ContentPlaceHolderID="cphBody" runat="Server"> <div id="divError" runat="server" /> <asp:DropDownList runat="server" id="jobType" onselectedindexchange="On_jobTypeSelection_Change"></asp:DropDownList> </asp:Content> I have also tried adding the event on the code behind like: protected void Page_Load(object sender, EventArgs e) { jobType.SelectedIndexChanged += new System.EventHandler(this.On_jobTypeSelection_Change); if (!IsPostBack) { JobStatus_DA da = new JobStatus_DA(); jobType.DataSource = da.getJobTypes(); jobType.DataBind(); } } protected void On_jobTypeSelection_Change(Object sender, EventArgs e) { //do something here } Can anybody help? Regards,

    Read the article

  • WPF ProgressBar - TargetParameterCountException

    - by Dr_Asik
    I am making my first WPF application, where I use the Youtube .NET API to upload a video to Youtube using the ResumableUploader. This ResumableUploader works asynchronously and provides an event AsyncOperationProgress to periodically report its progress percentage. I want a ProgressBar that will display this progress percentage. Here is some of the code I have for that: void BtnUpload_Click(object sender, RoutedEventArgs e) { // generate video uploader = new ResumableUploader(); uploader.AsyncOperationCompleted += OnDone; uploader.AsyncOperationProgress += OnProgress; uploader.InsertAsync(authenticator, newVideo.YouTubeEntry, new UserState()); } void OnProgress(object sender, AsyncOperationProgressEventArgs e) { Dispatcher.BeginInvoke((SendOrPostCallback)delegate { PgbUpload.Value = e.ProgressPercentage; }, DispatcherPriority.Background, null); } Where PgbUpload is my progress bar and the other identifiers are not important for the purpose of this question. When I run this, OnProgress will be hit a few times, and then I will get a TargetParameterCountException. I have tried several different syntax for invoking the method asynchronously, none of which worked. I am sure the problem is the delegate because if I comment it out, the code works fine (but the ProgressBar isn't updated of course). Thanks for any help.

    Read the article

  • c# deleting whole row in access database

    - by user2978474
    I have question about my problem. Thru manustrip in form1 i have made new form2 when i click on a right option. This form is for deleting data in access database if you pick in combobox ID of row it deletes the whole row wher is ID 4 or somethig else... My combobox is connected on my database. my code: public partial class Form2 : Form { public string myConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Bojan\Desktop\Programiranje\School\Novo\Novo\Ure.accdb"; // to je provider za Access 2007 in vec - ce ga ni na lokalni mašini ga je treba namestiti!!! public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'dataSet1.Ure' table. You can move, or remove it, as needed. this.ureTableAdapter.Fill(this.dataSet1.Ure); } private void Brisanje_Click(object sender, EventArgs e) { OleDbConnection myConnection = null; myConnection = new OleDbConnection(); // kreiranje konekcije myConnection.ConnectionString = myConnectionString; myConnection.Open(); OleDbCommand cmd = myConnection.CreateCommand(); cmd.Connection = myConnection; cmd.CommandText = "DELETE FROM Ure WHERE (ID) = '"+Izbor.SelectedValue+"'"; cmd.ExecuteNonQuery(); cmd.Prepare(); myConnection.Close(); } } Thanks for your help

    Read the article

  • serial port does not exist in current context: c#

    - by I__
    here's the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public class ThreadWork { private static SerialPort serialPort1; public static void DoWork() { serialPort1.Open(); serialPort1.Write("AT+CMGF=1\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CNMI=2,2\r\n"); //Thread.Sleep(500); serialPort1.Write("AT+CSCA=\"+4790002100\"\r\n"); //Thread.Sleep(500); serialPort1.DataReceived += serialPort1_DataReceived_1; } } private void Form1_Load(object sender, EventArgs e) { ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.Start(); } private void serialPort1_DataReceived_1(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string response = serialPort1.ReadLine(); this.BeginInvoke(new MethodInvoker(() => textBox1.AppendText(response + "\r\n"))); } } } and i get an error on this line: string response = serialPort1.ReadLine(); it says:: Error 1 The name 'serialPort1' does not exist in the current context C:\Users\alexluvsdanielle\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 44 31 WindowsFormsApplication1 what am i doing wrong?

    Read the article

  • How to move from custom to transluscent NavigationBar and back? Display problems!

    - by jd291
    So, i got this Navigation-based App (with a custom NavigationBar - Category) and I have 2 problems here... @implementation UINavigationBar (Custom) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed: @"bg_toolbar.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end Because of the Navigation-based App, most of the views have a height of 436px (= ScreenSize - NavigationBar height, as you probably know ;). I got one view similar to the photo app overview showing all the thumbnails, from there I push a viewcontroller containing the scroll view (like in photos app) on the stack, like so - (void)buttonPressed:(id)sender { UIButton *btn = (UIButton *)sender; PhotoSetScrollViewController *psc = [[PhotoSetScrollViewController alloc] initWithPhotoArray:photos andID:btn.tag]; [self.navigationController pushViewController:psc animated:YES]; } Problem 1: The view holding the fullscreen scrollview has a height of 480px which seems to be a problem because when poping the viewcontroller by hitting the back button, the view containing the thumbnails (height 436px) moves upward below the navigation bar. And also the Toolbar keeps showing. What could be the problem? Problem 2: How could I switch between my custom navigation bar and the standard black translucent style?

    Read the article

  • What does "Value does not fall within expected range" mean in runtime error?

    - by manuel
    Hi, I'm writing a plugin (dll file) using /clr and trying to implement speech recognition using .NET. But when I run it, I got a runtime error saying "Value does not fall within expected range", what does the message mean? public ref class Dialog : public System::Windows::Forms::Form { public: SpeechRecognitionEngine^ sre; private: System::Void btnSpeak_Click(System::Object^ sender, System::EventArgs^ e) { Initialize(); } protected: void Initialize() { //create the recognition engine sre = gcnew SpeechRecognitionEngine(); //set our recognition engine to use the default audio device sre->SetInputToDefaultAudioDevice(); //create a new GrammarBuilder to specify which commands we want to use GrammarBuilder^ grammarBuilder = gcnew GrammarBuilder(); //append all the choices we want for commands. //we want to be able to move, stop, quit the game, and check for the cake. grammarBuilder->Append(gcnew Choices("play", "stop")); //create the Grammar from th GrammarBuilder Grammar^ customGrammar = gcnew Grammar(grammarBuilder); //unload any grammars from the recognition engine sre->UnloadAllGrammars(); //load our new Grammar sre->LoadGrammar(customGrammar); //add an event handler so we get events whenever the engine recognizes spoken commands sre->SpeechRecognized += gcnew EventHandler<SpeechRecognizedEventArgs^> (this, &Dialog::sre_SpeechRecognized); //set the recognition engine to keep running after recognizing a command. //if we had used RecognizeMode.Single, the engine would quite listening after //the first recognized command. sre->RecognizeAsync(RecognizeMode::Multiple); //this->init(); } void sre_SpeechRecognized(Object^ sender, SpeechRecognizedEventArgs^ e) { //simple check to see what the result of the recognition was if (e->Result->Text == "play") { MessageBox(plugin.hwndParent, L"play", 0, 0); } if (e->Result->Text == "stop") { MessageBox(plugin.hwndParent, L"stop", 0, 0); } } };

    Read the article

  • Problems updating a textBox ASP.NET

    - by Roger Filipe
    Hello, I'm starting in asp.net and am having some problems that I do not understand. The problem is this, I am building a site for news. Every news has a title and body. I have a page where I can insert news, this page uses a textbox for each of the fields (title and body), after clicking the submit button everything goes ok and saves the values in the database. And o have another page where I can read the news, I use labels for each of the camps, these labels are defined in the Page_Load. Now I'm having problems on the page where I can edit the news. I am loading two textboxes (title and body) in the Page_Load, so far so good, but then when I change the text and I click the submit button, it ignores the changes that I made in the text and saves the text loaded in Page_Load. This code doesn't show any database connection but you can understand what i'm talking about. protected void Page_Load(object sender, EventArgs e) { textboxTitle.Text = "This is the title of the news"; textboxBody.Text = "This is the body of the news "; } I load the page, make the changes in the text , and then click submit. protected void btnSubmit_Click(object sender, EventArgs e) { String title = textboxTitle.Text; String body = textboxBody.Text; Response.Write("Title: " + title + " || "); Response.Write("Body: " + body ); } Nothing happens, the text in the textboxes is always the one I loaded in the page_load, how do I update the Text in the textboxes?

    Read the article

  • WPF validation on Enter Key Up

    - by Martin
    I'm trying to validate a UI change when Enter key is pressed. The UI element is a textbox, which is data binded to a string. My problem is that the data binding hasn't updated TestText when Enter key is Up. It is only updated when I press the button which brings up a message box. /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window, INotifyPropertyChanged { String _testText = new StringBuilder("One").ToString(); public string TestText { get { return _testText; } set { if (value != _testText) { _testText = value; OnPropertyChanged("TestText"); } } } public Window1() { InitializeComponent(); myGrid.DataContext = this; } private void OnPropertyChanged(string property) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(property)); } } public event PropertyChangedEventHandler PropertyChanged; private void onKeyUp(object sender, KeyEventArgs e) { if (e.Key != System.Windows.Input.Key.Enter) return; System.Diagnostics.Trace.WriteLine(TestText); } private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show(TestText); } } Window XAML: Window x:Class="VerificationTest.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" KeyUp="onKeyUp" TextBox XAML: TextBox Name="myTextBox" Text="{Binding TestText}" Button XAML: Button Name="button1" Click="button1_Click"

    Read the article

  • iPhone code forUIImageViewControllerPickerSourceTypeCamera

    - by aman-gupta
    - (IBAction)pickAndDecode:(id) sender { UIImagePickerControllerSourceType sourceType; int i = [sender tag]; switch (i) { case 0: sourceType = UIImagePickerControllerSourceTypeCamera; break; case 1: sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; break; case 2: sourceType = UIImagePickerControllerSourceTypePhotoLibrary; break; default: sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; } [self pickAndDecodeFromSource:sourceType]; } - (void) updateToolbar { self.cameraBarItem.enabled = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]; self.savedPhotosBarItem.enabled = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]; self.libraryBarItem.enabled = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]; self.archiveBarItem.enabled = true; self.actionBarItem.enabled = (self.result != nil) && ([self.result actions] != nil) && ([self.result actions].count > 0); } - (void)pickAndDecodeFromSource:(UIImagePickerControllerSourceType) sourceType { [self reset]; // Create the Image Picker if ([UIImagePickerController isSourceTypeAvailable:sourceType]) { UIImagePickerController* picker = [[UIImagePickerController alloc] init]; picker.sourceType = sourceType; picker.delegate = self; picker.allowsImageEditing = YES; // [[NSUserDefaults standardUserDefaults] boolForKey:@"allowEditing"]; // Picker is displayed asynchronously. [self presentModalViewController:picker animated:YES]; } else { NSLog(@"Attempted to pick an image with illegal source type '%d'", sourceType); } } Where I Put this line in my above codes; [picker setShowsCameraControls:FALSE]; please help me so that i can change the real view of iPhone camera according to my view which i have designed

    Read the article

  • Radiobutton in iphone

    - by Harita
    hi, i am using radio button image (empty circle) in button to answer the question from 3 options, and the 3 options are radio button's. i have created 3 uibuttons programmatically in tableview delegate method cellforrowatindexpath. i need when one button is selected(with filled circle image) other one if selected before gets unselected. i am using below code in button clicked method. static int _row; -(IBAction) optionClicked:(id)sender { UIButton *btn = (UIButton)sender; _row = btn.tag; if (btn.tag == 0) { if(btn1On) { [btnrad1 setImage:[UIImage imageNamed:@"unfilled.png"]forState:UIControlStateNormal]; btn1On=FALSE; } else { [btnrad1 setImage:[UIImage imageNamed:@"filled.png"]forState:UIControlStateNormal]; btn1On = TRUE; btn2On = FALSE; btn3On = FALSE; } } else if (btn.tag == 1) { if(btn2On) { [btnrad2 setImage:[UIImage imageNamed:@"unfilled.png"]forState:UIControlStateNormal]; btn2On=FALSE; } else { [btnrad2 setImage:[UIImage imageNamed:@"filled.png"]forState:UIControlStateNormal]; btn2On = TRUE; btn1On = FALSE; btn3On = FALSE; } } else if (btn.tag == 2) { if(btn3On) { [btnrad3 setImage:[UIImage imageNamed:@"unfilled.png"]forState:UIControlStateNormal]; btn3On=FALSE; } else { [btnrad3 setImage:[UIImage imageNamed:@"filled.png"]forState:UIControlStateNormal]; btn3On = TRUE; btn1On = FALSE; btn2On = FALSE; } } else { NSLog(@"Error"); } } above code is doing selection of button in another row. like i am selecting 1st option in 1st row but its is selecting 2nd row button. i don't know how to use _row to check for every cell of table view.

    Read the article

  • how to make changes to database in WPF?

    - by user353573
    Drag access database into designer xsd, toolkit:datagrid get datacontext from resources correctly show the table content through this binding. Press button in the button column, can show each row correctly. delete row and add row also work in datagrid however, when i press button column to add a new row or delete a row, there is no change in the underlying database, how to commit the changes from datagrid to database in WPF if not using ADO.net ? The following code is what i try do not work private void datagrid2_delete(object sender, RoutedEventArgs e) { Button showButton = (Button)sender; //person p = (person)showButton.DataContext; DataRowView ds = (DataRowView)showButton.DataContext; //DataSet1.customertableRow p = (DataSet1.customertableRow)ds; //ds.BeginEdit(); //ds.Delete(); //ds.EndEdit(); /* DataSourceProvider provider = (DataSourceProvider)this.FindResource("Family"); WpfApplication1.DataSet1.customertableDataTable table = (WpfApplication1.DataSet1.customertableDataTable)provider.Data; table.AddcustomertableRow("hello3", 5, System.DateTime.Today); table.AcceptChanges(); }

    Read the article

  • C# Minimize all running windows when application runs

    - by Derek
    I am working on a C# windows form application. How can i edit my code in a way that when more than 2 faces is being detected by my webcam. More information: When "FaceDetectedLabel.Text = "Faces Detected : " + cam.facesdetected.ToString();" becomes Face Detected: 2 or more... How can i do the following: Minimize all program running except my application. Log out of my computer Here is my code: namespace PBD { public partial class MainPage : Form { //declaring global variables private Capture capture; //takes images from camera as image frames public MainPage() { InitializeComponent(); } private void ProcessFrame(object sender, EventArgs arg) { Wrapper cam = new Wrapper(); //show the image in the EmguCV ImageBox WebcamPictureBox.Image = cam.start_cam(capture).Resize(390, 243, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC).ToBitmap(); FaceDetectedLabel.Text = "Faces Detected : " + cam.facesdetected.ToString(); } private void MainPage_Load(object sender, EventArgs e) { #region if capture is not created, create it now if (capture == null) { try { capture = new Capture(); } catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); } } #endregion Application.Idle += ProcessFrame; }

    Read the article

  • How to decrypt a string encrypted with HMACSHA1?

    - by Bob
    I'm an encryption novice trying to pass some values back and forth between systems. I can encrypt the value, but can't seem to figure out how to decrypt on the other end. I've created a simple Windows Forms application using VB.NET. Trying to input a value and a key, encrypt and then decrypt to get the original value. Here's my code so far. Any help greatly appreciated. Thanks. Imports System Imports System.IO Imports System.Security.Cryptography Imports System.Text Public Class Form1 Private Sub btnEncode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncode.Click Dim hmacsha1 As New HMACSHA1(Encoding.ASCII.GetBytes(txtKey.Text)) Dim hashValue As Byte() = hmacsha1.ComputeHash(Encoding.ASCII.GetBytes(txtValue.Text)) txtResult.Text = BytesToHexString(hashValue) hmacsha1.Clear() End Sub Private Sub btnDecode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecode.Click '??? End Sub Private Function BytesToHexString(ByVal bytes As Byte()) As String Dim output As String = String.Empty Dim i As Integer = 0 Do While i < bytes.Length output += bytes(i).ToString("X2") i += 1 Loop Return output End Function End Class

    Read the article

  • .NET MissingMethodException occuring on one of thousands of end-user machines -- any insight?

    - by Yoooder
    This issue has me baffled, it's affecting a single user (to my knowledge) and hasn't been reproduced by us... The user is receiving a MissingMethodException, our trace file indicates it's occuring after we create a new instance of a component, when we're calling an Initialize/Setup method in preparation to have it do work (InitializeWorkerByArgument in the example) The Method specified by the error is an interface method, which a base class implements and classes derived from the base class can override as-needed The user has the latest release of our application All the provided code is shipped within a single assembly Here's a very distilled version of the component: class Widget : UserControl { public void DoSomething(string argument) { InitializeWorkerByArgument(argument); this.Worker.DoWork(); } private void InitializeWorkerByArgument(string argument) { switch (argument) { case "SomeArgument": this.Worker = new SomeWidgetWorker(); break; } // The issue I'm tracking down would have occured during "new SomeWidgetWorker()" // and would have resulted in a missing method exception stating that // method "DoWork" could not be found. this.Worker.DoWorkComplete += new EventHandler(Worker_DoWorkComplete); } private IWidgetWorker Worker { get; set; } void Worker_DoWorkComplete(object sender, EventArgs e) { MessageBox.Show("All done"); } } interface IWidgetWorker { void DoWork(); event EventHandler DoWorkComplete; } abstract class BaseWorker : IWidgetWorker { virtual public void DoWork() { System.Threading.Thread.Sleep(1000); RaiseDoWorkComplete(this, null); } internal void RaiseDoWorkComplete(object sender, EventArgs e) { if (DoWorkComplete != null) { DoWorkComplete(this, null); } } public event EventHandler DoWorkComplete; } class SomeWidgetWorker : BaseWorker { public override void DoWork() { System.Threading.Thread.Sleep(2000); RaiseDoWorkComplete(this, null); } }

    Read the article

< Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >