Search Results

Search found 10381 results on 416 pages for 'delegate and events'.

Page 67/416 | < Previous Page | 63 64 65 66 67 68 69 70 71 72 73 74  | Next Page >

  • About global.asax and the events there

    - by eski
    So what i'm trying to understand is the whole global.asax events. I doing a simple counter that records website visits. I am using MSSQL. Basicly i have two ints. totalNumberOfUsers - The total visist from begining. currentNumberOfUsers - Total of users viewing the site at the moment. So the way i understand global.asax events is that every time someone comes to the site "Session_Start" is fired once. So once per user. "Application_Start" is fired only once the first time someone comes to the site. Going with this i have my global.asax file here. <script runat="server"> string connectionstring = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString; void Application_Start(object sender, EventArgs e) { // Code that runs on application startup Application.Lock(); Application["currentNumberOfUsers"] = 0; Application.UnLock(); string sql = "Select c_hit from v_counter where (id=1)"; SqlConnection connect = new SqlConnection(connectionstring); SqlCommand cmd = new SqlCommand(sql, connect); cmd.Connection.Open(); cmd.ExecuteNonQuery(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Application.Lock(); Application["totalNumberOfUsers"] = reader.GetInt32(0); Application.UnLock(); } reader.Close(); cmd.Connection.Close(); } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started Application.Lock(); Application["totalNumberOfUsers"] = (int)Application["totalNumberOfUsers"] + 1; Application["currentNumberOfUsers"] = (int)Application["currentNumberOfUsers"] + 1; Application.UnLock(); string sql = "UPDATE v_counter SET c_hit = @hit WHERE c_type = 'totalNumberOfUsers'"; SqlConnection connect = new SqlConnection(connectionstring); SqlCommand cmd = new SqlCommand(sql, connect); SqlParameter hit = new SqlParameter("@hit", SqlDbType.Int); hit.Value = Application["totalNumberOfUsers"]; cmd.Parameters.Add(hit); cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); } void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised. Application.Lock(); Application["currentNumberOfUsers"] = (int)Application["currentNumberOfUsers"] - 1; Application.UnLock(); } </script> In the page_load i have this protected void Page_Load(object sender, EventArgs e) { l_current.Text = Application["currentNumberOfUsers"].ToString(); l_total.Text = Application["totalNumberOfUsers"].ToString(); } So if i understand this right, every time someone comes to the site both the currentNumberOfUsers and totalNumberOfUsers are incremented with 1. But when the session is over the currentNumberOfUsers is decremented with 1. If i go to the site with 3 types of browsers with the same computer i should have 3 in hits on both counters. Doing this again after hours i should have 3 in current and 6 in total, right ? The way its working right now is the current goes up to 2 and the total is incremented on every postback on IE and Chrome but not on firefox. And one last thing, is this the same thing ? Application["value"] = 0; value = Application["value"] //OR Application.Set("Value", 0); Value = Application.Get("Value");

    Read the article

  • What data to send when tracking clicks with Google Analytics events (and how)?

    - by user359650
    When tracking clicks on links, there are 3 items I'm interested in: link location in the page by grabbing the id of the closest parent: to see influence of location on click-through link text: to see influence of text on click-through link href attribute value: to see where people go when leaving my website The problem when using Google Analytics to track those clicks is that events only have 3 available text fields, one of which being the category, which if you use to store one of the above items will create a mess in your Event reporting because you will have as many categories as item values. Therefore if you assign a predefined value to the category (e.g. clicks), then you're left with only 2 event fields (action, label) to store 3 items (location, text, href). That in itself isn't the end of the world because you can concatenate 2 items into 1 event field, then use the reporting or the API to filter things out. Accordingly what I plan on doing is this: category: clicks action: {location_on_page} ¦ {text} label: {href} where {__} are variable values related to the clicked links With this I can easily create some reports directly via the GUI: downloads: include only events where label ends with .pdf click outs to particular domains: include only events where label contains domain And for more complex tasks I need to export the data (or use the API): influence of location on clicks: for each location in the design, count number of events that have that location in the action, then corroborate with pageviews of the corresponding pages. Whilst this looks good I'm wondering if there is a better approach, hence the following questions: Q1: Can you foresee any particular issues with this particular setup (e.g. things I won't be able to report on)? Q2: Can you think of other data that would be interesting to include in the event?

    Read the article

  • UIButton in UITableViewCell events not working

    - by Tristan
    I see this problem all over the net, and none of the solutions listed work for me! I have added UIButton to a UITableViewCell in IB. I have assigned a custom UITableViewCell class to the UITableViewCell. My custom UITableViewCell class has an IBAction that im connecting to the Touch Up Inside event (I have tried other events they all don't work) but the IBAction function is never called! There is nothing else in the UITableViewCell, I have added the UIButton directly into the Content View. And everything has user interaction enabled! It is as simple as that I have nothing complex going on! What is is about a UITableViewCell that stops buttons working? EDIT: By request the code where I initialize my UITableViewCells the custom class is called DownloadCell - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"DownloadCell"; DownloadCell *cell = (DownloadCell *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { UIViewController * cellController = [[UIViewController alloc] initWithNibName:@"DownloadCell" bundle:nil]; cell = (DownloadCell *)cellController.view; [cellController release]; } SoundLibrarianIPhoneAppDelegate * del = (SoundLibrarianIPhoneAppDelegate *)[UIApplication sharedApplication].delegate; DownloadQueue * dq = del.downloadQueue; DownloadJob * job = [dq getDownloadJob: indexPath.row]; [job setDelegate:self]; SoundInfo * info = [job sound]; NSArray * seperated = [info.fileName componentsSeparatedByString: @"."]; NSString * displayName = [seperated objectAtIndex:0]; displayName = [displayName stringByReplacingOccurrencesOfString:@"_" withString:@" "]; displayName = [displayName capitalizedString]; [cell.titleLabel setText: displayName]; cell.progressBar.progress = job.percentCompleted; [cell.progressLabel setText: [job getProgessText]]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.userInteractionEnabled = YES; [cell setDelegate:self]; return cell; }

    Read the article

  • How to hook up WF4 WorkflowRuntime events when using a XAMLX service

    - by Joel D'Souza
    I'm currently using a BehaviorExtensionElement to load a ServiceBehavior where the ApplyDispatchBehavior method is set up as: public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost; if (host != null) { UnityService.CreateContainer(); host.WorkflowExtensions.Add<IUnityContainer>(delegate { return UnityService.CreateChildContainer(); }); System.Diagnostics.Debug.WriteLine("NotificationService : Adding extension"); WorkflowRuntimeBehavior wfbehavior = serviceDescription.Behaviors.Find<WorkflowRuntimeBehavior>(); WorkflowRuntime runtime = wfbehavior.WorkflowRuntime; runtime.WorkflowStarted += runtime_WorkflowStarted; runtime.WorkflowCreated += runtime_WorkflowCreated; runtime.WorkflowUnloaded += runtime_WorkflowUnloaded; runtime.WorkflowSuspended += runtime_WorkflowSuspended; runtime.WorkflowCompleted += runtime_WorkflowCompleted; runtime.WorkflowAborted += runtime_WorkflowAborted; runtime.WorkflowTerminated += runtime_WorkflowTerminated; } } None of the events are triggered which only goes to say that the way I'm referencing the runtime instance in this particular scenario is wrong. Anyone know of a way to do this? Thanks in advance.

    Read the article

  • Convert C# (with typed events) to VB.NET

    - by Steven
    I have an ASPX page (with VB Codebehind). I would like to extend the GridView class to show the header / footer when no rows are returned. I found a C# example online (link) (source). However, I cannot convert it to VB because it uses typed events (which are not legal in VB). I have tried several free C# to VB.NET converters online, but none have worked. Please convert the example to VB.NET or provide an alternate method of extending the GridView class. Notes / Difficulties: If you get an error with DataView objects, specify the type as System.Data.DataView and the type comparison could be the following: If data.[GetType]() Is GetType(System.Data.DataView) Then Since the event MustAddARow cannot have a type in VB (and RaiseEvent event doesn't have a return value), how can I compare it to Nothing in the function OnMustAddARow()? EDIT: The following is a sample with (hopefully) relevant code to help answer the question. namespace AlwaysShowHeaderFooter { public delegate IEnumerable MustAddARowHandler(IEnumerable data); public class GridViewAlwaysShow : GridView { ////////////////////////////////////// // Various member functions omitted // ////////////////////////////////////// protected IEnumerable OnMustAddARow(IEnumerable data) { if (MustAddARow == null) { throw new NullReferenceException("The datasource has no rows. You must handle the \"MustAddARow\" Event."); } return MustAddARow(data); } public event MustAddARowHandler MustAddARow; } }

    Read the article

  • Help regarding JavaScript events

    - by Anil Namde
    I have a table full of cells and i would like to get on which cell the mouse is. For this i have attached events to all the cells and then i am finding the elements. But i guess there could be a better options. right ? Is it possible that i attach only single event handler on top and still be able to catch all the information. like which cell user is currently on etc. Something like below, <table onMouseOver="monitorFuntion(event)" >...</table>

    Read the article

  • C#: Excel 2007 Addin, How to Hook Windows Activate and Deactivate Events

    - by user127490
    I am writing an Excel 2007 Addin. using VS2008 and .net 3.5, C#. I catched Microsoft.Office.Interop.Excel.Application's WindowActivate and WindowDeActivate events. It was surprised to know that WindowActivate and Deactivate only triggers when i switch between two Excel Windows. if i switch to notepad, i expect Deactivate to be triggered, but its not happening. same way from notepad if i switch to excel window, i expect Activate to be triggered but its not happening. It looks like the behaviour indicates windows are MDI-Child windows. Now what i want to do is get HWnd of Excel's Mainwindow and hook Window Activate and Deactivates using dllimport features. Can anyone guide to me on this. Regards

    Read the article

  • Best way to display a list of events by month

    - by EmmyS
    I have a mySQL table of events and want to display them in a list using PHP. Pretty simple, except I only want to display the month name once, for example: May 2010 12th, 7 pm. Event 1 - event one description 15th, 5:30 pm. Event 2 - event two description June 2010 9th, 7 pm. Event 1 - event one description 11th, 5:30 pm. Event 2 - event two description I'm very new at SQL and PHP. I can think of one way to do it. It would involve selecting all records grouped by date, then looping through all records, comparing the month/year value each time and the first time the month/year doesn't match, print a new header row to my HTML table. I can't believe it's the best or most efficient way to go. Any ideas for a newbie? I'm sure my way would work, but it's inelegant at best, and processor-intensive at worst.

    Read the article

  • AJAX binds jquery events multiple times

    - by Dynde
    Hi... I have a masterpage setup, with a pageLoad in the topmost masterpage, which calls pageLoad2 for nested masterpages which calls pageLoad3 for content pages. In my content page I have a jquery click event and in my nested masterpage I have a web user control. Whenever I use the user control in the nested masterpage, it rebinds the click event in the content page (undoubtedly because the pageLoad3 is called again), but this makes the click event fire twice on a single click. The problem gets worse the higher up masterpages you go (eg. fires 3 times if user control from topmost masterpage is called). Can anyone tell me how to make sure it only binds the jquery events once?

    Read the article

  • Binding multiple events in jQuery

    - by Lachlan McDonald
    I have a custom jQuery plugin which binds a change event to a form element, in this case some input elements. The change event is used to indicate to some other components that a change has taken place. This works as it should. However, I've come across the need to bind an additional change event to the same input elements -- so that additional components can act on the event. I don't wish to replace the plugin's change, simply run an additional function afterwards. Is there any way to bind multiple events in jQuery, or, what is the best method for accomplishing this?

    Read the article

  • Help me understand JavaScript events

    - by Anil Namde
    I have a table full of cells and i would like to get on which cell the mouse is. For this i have attached events to all the cells and then i am finding the elements. But i guess there could be a better options. right ? Is it possible that i attach only single event handler on top and still be able to catch all the information. like which cell user is currently on etc. Something like below, <table onMouseOver="monitorFuntion(event)" >...</table>

    Read the article

  • Using TextboxList events and callbacks

    - by Wraith
    Has anyone gotten callbacks working with Guillermo Rauch's TextboxList Autocomplete? I've tried multiple ways to bind and multiple events (e.g. hover) - nothing seems to register. $('#entSearch').textboxlist({unique: true, plugins: { autocomplete: { minLength: 3, queryRemote: true, placeholder: false, remote: { url: "{{=URL(r=request, f='call/json/suggest')}}", extraParams: {type: "", guid: ""} } } }, onHover: function(token) { alert('hover 1'); } }); $('#entSearch').hover(function() { alert('hover 2'); }); $('#entSearch').bind('hover', function() { alert('hover 3'); });

    Read the article

  • Namespaced Backbone.js Views not firing events

    - by Stasio
    I'm currently getting started with Backbone.js. I've wrote some examples with Backbone and they are working fine. But now I need to use Backbone.js with Rails 3.1 and CoffeeScript. I took my well-working examples and rewrote on CoffeeScript using backbone-rails gem. And got the following problem. I've simplyfied code, but the problem is still remaining I've got the following files: Here I'm starting my Backbone app at main.js.coffee file according to my main_controller in rails app: $ = jQuery $-> CsfTaskManager.init() Here is backbone app description: #= require_self #= require_tree ./templates #= require_tree ./models #= require_tree ./views #= require_tree ./routers window.CsfTaskManager = Models: {} Collections: {} Routers: {} Views: {} init: -> new CsfTaskManager.Routers.AppRouter() Backbone.history.start() This is my apps' router: class CsfTaskManager.Routers.AppRouter extends Backbone.Router initialize: (options) -> goalsBlock = new CsfTaskManager.Views.goalsView() routes: "!/": "root", some other routes... And finally view: class CsfTaskManager.Views.goalsView extends Backbone.View initialize: -> this.goals = new CsfTaskManager.Collections.GoalsCollection() el: $('div#app'), events: "click .add-btn": "addGoal" addGoal: -> alert('ji') HTML page has such code: <div id="app"> <div class="app-screen hidden" id="goal-form" style="display: block; "> <button class="btn" id="load"> Load </button> <h3> New Goal </h3> <div class="form-stacked"> <form accept-charset="UTF-8" action="/goals" class="new_goal" id="new_goal" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="?"><input name="authenticity_token" type="hidden" value="Pnt+V/tS1/b079M/1ZIRdw2ss1D6bvJKVh868DXRjUg="></div> <label for="goal_title">Title</label> <p></p> <input class="goal-title" id="goal_title" name="goal[title]" size="30" type="text"> <p></p> <label for="goal_note">Note</label> <p></p> <input class="goal-note" id="goal_note" name="goal[note]" size="30" type="text"> </form> </div> <p> <button class="add-btn btn"> Add </button> </p> <ul id="goals-list"></ul> </div> <table class="app-screen bordered-table" id="calendar-grid" style="display: none; "> <tbody><tr> <td colspan="2"> week </td> </tr> <tr> <td> day </td> <td> <div id="calendar"></div> </td> </tr> </tbody></table> <div class="app-screen hidden" id="role-form" style="display: none; "> <h3> New User Role </h3> <div class="form-stacked"> <form accept-charset="UTF-8" action="/roles" class="new_role" id="new_role" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="?"><input name="authenticity_token" type="hidden" value="Pnt+V/tS1/b079M/1ZIRdw2ss1D6bvJKVh868DXRjUg="></div> <label for="role_title">Title</label> <p></p> <input class="role-title" id="role_name" name="role[name]" size="30" type="text"> <p></p> <label for="role_note">Note</label> <p></p> <input class="role-note" id="role_description" name="role[description]" size="30" type="text"> </form> </div> <p> <button class="add-btn btn"> Add </button> </p> </div> </div> So .add-btn element is nested in #app, but click on this button doesn't fire event. Where can be a trouble? Before, when I had the same app in one .js file, without of coffeescript, namespacing and backbone-rails gem, everything was allright. Bytheway, appRouter works fine, goalsView object is created successfully too, but events don't fire for some reasons. Please give me some hint, because I'm really got stuck...

    Read the article

  • How to handle both the KeyDown and KeyUp events in a Silverlight 3 TextBox

    - by sako73
    I am attaching handlers to the KeyDown and KeyUp events of a Silverlight 3 TextBox as so: _masterTextBox.KeyDown += (s, args) => { CheckForUserEnteredText(MasterTextBox.Text); args.Handled = false; }; _masterTextBox.KeyUp += (s, args) => { UpdateText(MasterTextBox.Text); }; When I comment out the KeyDown handler, then the KeyUp will trap the event, otherwise, only the KeyDown handler is triggered. Can someone explain why the KeyUp event handler is not firing after the KeyDown handler does? Thanks.

    Read the article

  • Why can event handlers can only be bound to HttpApplication events during IHttpModule initialization

    - by Venemo
    This is just another "working in dev server, why not working in IIS" type question. So, I created a nice DAL using NHibernate as described here. When creating an ISession, I hook up an event handler to the HttpApplication.EndRequest to take care of cleaning it up. However, I deployed my site to IIS and it says: Event handlers can only be bound to HttpApplication events during IHttpModule initialization. Since when? What for? Why? How can I bypass it?

    Read the article

  • PHP AJAX mysql event calendar - UI for events spanning multiple days

    - by play
    I have built a PHP calendar system and have pretty much everything done but not sure how to deal with a UI issue involving how the events that stretched out over a couple of days. I want to be able to stretch an event that stretches over couple of days in a div that spans those days in the calendar. Basically I would like to know how to achieve what these guys have achieved with the event that stretches out from 21st to 22nd with the yellow div background. I have been trying to see how I can do it with PHP but I feel like I might be trying the wrong thing. Perhaps this is done with javascript?

    Read the article

  • success, error events aren't working for ajax

    - by Rigo Vides
    Hi everyone, I have the following code: $(document).ready(function(){ $.ajax({ url: "svc/GetTweetsByUser.php", type: "POST", success: function(data) { alert('success'); }, failure: function(){ alert('fail'); }, data: ({twitter_user : 'AdoboHobo'}), dataType: "xml" } );//endof ajax }); I'm kind of starting with web and ajax stuff... this worked perfectly by yesterday. I don't know what is happening now that neither success nor failure events are triggering. I'm shure that the request and response are perfectly working, I checked that with firebug. Does anyone have any ideas for this? Thanks in advance.

    Read the article

  • Handling events exposed on a .NET class via COM in VB6

    - by PeanutPower
    Handling events exposed on a .NET class via COM in VB6 My test .NET (class libary registered for interop in compiler settings) code: Imports System.Runtime.InteropServices <InterfaceType(ComInterfaceType.InterfaceIsIDispatch), ComVisible(True)> _ Public Interface MyEventInterface <DispId(1)> Event Exploded(ByVal Text As String) <DispId(2)> Sub PushRedButton() End Interface <ClassInterface(ClassInterfaceType.None)> _ Public Class EventTest Implements MyEventInterface Public Event Exploded(ByVal Text As String) Implements MyEventInterface.Exploded Public Sub PushRedButton() Implements MyEventInterface.PushRedButton RaiseEvent Exploded("Bang") End Sub End Class My test VB6 application winforms code (which references the above class libary): Public ct As New ComTest1.EventTest Private Sub Command1_Click() ct.add_Exploded (ExplodedHandler) ct.PushRedButton ct.remove_Exploded (ExplodedHandler) End Sub Private Sub ExplodedHandler(ByVal Text As String) MsgBox Text End Sub Specifially I'm not sure how to set up the handler in VB6 the compile error I get is "Argument not optional" on this line in the VB6: ct.add_Exploded (ExplodedHandler)

    Read the article

  • Native Mouse events with Flash and Selenium

    - by Dan at Demand
    I understand that Selenium does not support Flash, but it is my understanding that I should be able to do some simplistic testing of Flash by using Selenium's built in native mouse support and doing mouse up/down events based on coordinates. Is this correct? I can't seem to get it working. I'm trying to test on this page: http://mandy-mania.blogspot.com/2010/04/sneak-peek-of-final-season-of-lost-dvd.html and all I'm trying to do is click on the flash object so it plays the video. I've tried all sorts of commands, MouseOver, MouseDown, MouseDownAt, MouseUp, MouseUpAt, etc. So, I'm wondering if this just theoretically doesn't work or if I'm just doing something wrong. The xpath I'm using is //object[@id='player'], although I've tried a number of different combinations. And yes, I've also tried just the straight click command. Any suggestions? Thanks!

    Read the article

  • DataContext Refresh and PropertyChanging & PropertyChanged Events

    - by Scott
    I'm in a situation where I am being informed from an outside source that a particular entity has been altered outside my current datacontext. I'm able to find the entity and call refresh like so MyDataContext.Refresh(RefreshMode.OverwriteCurrentValues, myEntity); and the properties which have been altered on the entity are updated correctly. However neither of the INotifyPropertyChanging INotifyPropertyChanged appear to be raised when the refresh occurs and this leaves my UI displaying incorrect information. I'm aware that Refresh() fails to use the correct property getters and setters on the entity to raise the change notification events, but perhaps there is another way to accomplish the same thing? Am I doing something wrong? Is there a better method than Refresh? If Refresh is the only option, does anyone have a work around?

    Read the article

  • How to catch Keyboard and mouse events?

    - by Alexey Malistov
    I want to create an application. This application has to do something when a user presses special keys on keyboard or/and uses scroll wheel. This application is a service. It has no windows. I want to catch any keyboard or mouse events which were designed with other applications. For example, you are watching TV by 3rd party application. If you press Ctrl + Shift and use scroll wheel my application changes the volume. I use Windows 7 x64 and Visual Studio 2008.

    Read the article

  • EKCalendar not added to iCal

    - by Alex75
    I have a strange behavior on my iPhone. I'm creating an application that uses calendar events (EventKit). The class that use is as follows: the .h one #import "GenericManager.h" #import <EventKit/EventKit.h> #define oneDay 60*60*24 #define oneHour 60*60 @protocol CalendarManagerDelegate; @interface CalendarManager : GenericManager /* * metodo che aggiunge un evento ad un calendario di nome Name nel giorno onDate. * L'evento da aggiungere viene recuperato tramite il dataSource che è quindi * OBBLIGATORIO (!= nil). * * Restituisce YES solo se il delegate è conforme al protocollo CalendarManagerDataSource. * NO altrimenti */ + (BOOL) addEventForCalendarWithName:(NSString *) name fromDate:(NSDate *)fromDate toDate: (NSDate *) toDate withDelegate:(id<CalendarManagerDelegate>) delegate; /* * metodo che aggiunge un evento per giorno compreso tra fromDate e toDate ad un * calendario di nome Name. L'evento da aggiungere viene recuperato tramite il dataSource * che è quindi OBBLIGATORIO (!= nil). * * Restituisce YES solo se il delegate è conforme al protocollo CalendarManagerDataSource. * NO altrimenti */ + (BOOL) addEventsForCalendarWithName:(NSString *) name fromDate:(NSDate *)fromDate toDate: (NSDate *) toDate withDelegate:(id<CalendarManagerDelegate>) delegate; @end @protocol CalendarManagerDelegate <NSObject> // viene inviato quando il calendario necessita informazioni sull' evento da aggiungere - (void) calendarManagerDidCreateEvent:(EKEvent *) event; @end the .m one // // CalendarManager.m // AppCampeggioSingolo // // Created by CreatiWeb Srl on 12/17/12. // Copyright (c) 2012 CreatiWeb Srl. All rights reserved. // #import "CalendarManager.h" #import "Commons.h" #import <objc/message.h> @interface CalendarManager () @end @implementation CalendarManager + (void)requestToEventStore:(EKEventStore *)eventStore delegate:(id)delegate fromDate:(NSDate *)fromDate toDate: (NSDate *) toDate name:(NSString *)name { if([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) { // ios >= 6.0 [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) { if (granted) { [self addEventForCalendarWithName:name fromDate: fromDate toDate: toDate inEventStore:eventStore withDelegate:delegate]; } else { } }]; } else if (class_getClassMethod([EKCalendar class], @selector(calendarIdentifier)) != nil) { // ios >= 5.0 && ios < 6.0 [self addEventForCalendarWithName:name fromDate:fromDate toDate:toDate inEventStore:eventStore withDelegate:delegate]; } else { // ios < 5.0 EKCalendar *myCalendar = [eventStore defaultCalendarForNewEvents]; EKEvent *event = [self generateEventForCalendar:myCalendar fromDate: fromDate toDate: toDate inEventStore:eventStore withDelegate:delegate]; [eventStore saveEvent:event span:EKSpanThisEvent error:nil]; } } /* * metodo che recupera l'identificativo del calendario associato all'app o nil se non è mai stato creato. */ + (NSString *) identifierForCalendarName: (NSString *) name { NSString * confFileName = [self pathForFile:kCurrentCalendarFileName]; NSDictionary *confCalendar = [NSDictionary dictionaryWithContentsOfFile:confFileName]; NSString *currentIdentifier = [confCalendar objectForKey:name]; return currentIdentifier; } /* * memorizza l'identifier del calendario */ + (void) saveCalendarIdentifier:(NSString *) identifier andName: (NSString *) name { if (identifier != nil) { NSString * confFileName = [self pathForFile:kCurrentCalendarFileName]; NSMutableDictionary *confCalendar = [NSMutableDictionary dictionaryWithContentsOfFile:confFileName]; if (confCalendar == nil) { confCalendar = [NSMutableDictionary dictionaryWithCapacity:1]; } [confCalendar setObject:identifier forKey:name]; [confCalendar writeToFile:confFileName atomically:YES]; } } + (EKCalendar *)getCalendarWithName:(NSString *)name inEventStore:(EKEventStore *)eventStore withLocalSource: (EKSource *)localSource forceCreation:(BOOL) force { EKCalendar *myCalendar; NSString *identifier = [self identifierForCalendarName:name]; if (force || identifier == nil) { NSLog(@"create new calendar"); if (class_getClassMethod([EKCalendar class], @selector(calendarForEntityType:eventStore:)) != nil) { // da ios 6.0 in avanti myCalendar = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:eventStore]; } else { myCalendar = [EKCalendar calendarWithEventStore:eventStore]; } myCalendar.title = name; myCalendar.source = localSource; NSError *error = nil; BOOL result = [eventStore saveCalendar:myCalendar commit:YES error:&error]; if (result) { NSLog(@"Saved calendar %@ to event store. %@",myCalendar,eventStore); } else { NSLog(@"Error saving calendar: %@.", error); } [self saveCalendarIdentifier:myCalendar.calendarIdentifier andName:name]; } // You can also configure properties like the calendar color etc. The important part is to store the identifier for later use. On the other hand if you already have the identifier, you can just fetch the calendar: else { myCalendar = [eventStore calendarWithIdentifier:identifier]; NSLog(@"fetch an old-one = %@",myCalendar); } return myCalendar; } + (EKCalendar *)addEventForCalendarWithName: (NSString *) name fromDate:(NSDate *)fromDate toDate: (NSDate *) toDate inEventStore:(EKEventStore *)eventStore withDelegate: (id<CalendarManagerDelegate>) delegate { // da ios 5.0 in avanti EKCalendar *myCalendar; EKSource *localSource = nil; for (EKSource *source in eventStore.sources) { if (source.sourceType == EKSourceTypeLocal) { localSource = source; break; } } @synchronized(self) { myCalendar = [self getCalendarWithName:name inEventStore:eventStore withLocalSource:localSource forceCreation:NO]; if (myCalendar == nil) myCalendar = [self getCalendarWithName:name inEventStore:eventStore withLocalSource:localSource forceCreation:YES]; NSLog(@"End synchronized block %@",myCalendar); } EKEvent *event = [self generateEventForCalendar:myCalendar fromDate:fromDate toDate:toDate inEventStore:eventStore withDelegate:delegate]; [eventStore saveEvent:event span:EKSpanThisEvent error:nil]; return myCalendar; } + (EKEvent *) generateEventForCalendar: (EKCalendar *) calendar fromDate:(NSDate *)fromDate toDate: (NSDate *) toDate inEventStore:(EKEventStore *) eventStore withDelegate:(id<CalendarManagerDelegate>) delegate { EKEvent *event = [EKEvent eventWithEventStore:eventStore]; event.startDate=fromDate; event.endDate=toDate; [delegate calendarManagerDidCreateEvent:event]; [event setCalendar:calendar]; // ricerca dell'evento nel calendario, se ne trovo uno uguale non lo inserisco NSPredicate *predicate = [eventStore predicateForEventsWithStartDate:fromDate endDate:toDate calendars:[NSArray arrayWithObject:calendar]]; NSArray *matchEvents = [eventStore eventsMatchingPredicate:predicate]; if ([matchEvents count] > 0) { // ne ho trovati di gia' presenti, vediamo se uno e' quello che vogliamo inserire BOOL found = NO; for (EKEvent *fetchEvent in matchEvents) { if ([fetchEvent.title isEqualToString:event.title] && [fetchEvent.notes isEqualToString:event.notes]) { found = YES; break; } } if (found) { // esiste già e quindi non lo inserisco NSLog(@"OH NOOOOOO!!"); event = nil; } } return event; } #pragma mark - Public Methods + (BOOL) addEventForCalendarWithName:(NSString *) name fromDate:(NSDate *)fromDate toDate: (NSDate *) toDate withDelegate:(id<CalendarManagerDelegate>) delegate { BOOL retVal = YES; EKEventStore *eventStore=[[EKEventStore alloc] init]; if ([delegate conformsToProtocol:@protocol(CalendarManagerDelegate)]) { [self requestToEventStore:eventStore delegate:delegate fromDate:fromDate toDate: toDate name:name]; } else { retVal = NO; } return retVal; } + (BOOL) addEventsForCalendarWithName:(NSString *) name fromDate:(NSDate *)fromDate toDate: (NSDate *) toDate withDelegate:(id<CalendarManagerDelegate>) delegate { BOOL retVal = YES; NSDate *dateCursor = fromDate; EKEventStore *eventStore=[[EKEventStore alloc] init]; if ([delegate conformsToProtocol:@protocol(CalendarManagerDelegate)]) { while (retVal && ([dateCursor compare:toDate] == NSOrderedAscending)) { NSDate *finish = [dateCursor dateByAddingTimeInterval:oneDay]; [self requestToEventStore:eventStore delegate:delegate fromDate: dateCursor toDate: finish name:name]; dateCursor = [dateCursor dateByAddingTimeInterval:oneDay]; } } else { retVal = NO; } return retVal; } @end In practice, on my iphone I get the log: fetch an old-one = (null) 19/12/2012 11:33:09.520 AppCampeggioSingolo [730:8 b1b] create new calendar 19/12/2012 11:33:09.558 AppCampeggioSingolo [730:8 b1b] Saved calendar EKCalendar every time I add an event, then I look and I can not find it on iCal calendar event he added. On the iPhone of a friend of mine, however, everything is working correctly. I doubt that the problem stems from the code, but just do not understand what it could be. I searched all day yesterday and part of today on google but have not found anything yet. Any help will be greatly appreciated EDIT: I forgot the call wich is [CalendarManager addEventForCalendarWithName: @"myCalendar" fromDate:fromDate toDate: toDate withDelegate:self]; in the delegate method simply set title and notes of the event like this - (void) calendarManagerDidCreateEvent:(EKEvent *) event { event.title = @"the title"; event.notes = @"some notes"; }

    Read the article

  • jquery performance of binding multiple click events.

    - by DA
    I have a situation where I need to bind a click event to an object multiple times. For instance: for(i=0;i<=100;i++){ $myObject.click(function(){ window.location = "myurl"+i+".html"; }) ...do other stuff... } Via that markup, does $myObject end up with 100 click events attached to it? Should I be unbinding the click event first each time? for(i=0;i<=100;i++){ $myObject.unbind('click').click(function(){ window.location = "myurl"+i+".html"; }) ...do other stuff... }

    Read the article

  • Game Key Events: Event or Method Overload?

    - by Ell
    If you were going to develop a game in say, Ruby, and you were provided with a game framework, would you rather act on key up/down events by overloading a method on the main window like so: class MyGameWindow < Framework::GameWindow def button_down(id) case id when UpArrow do_something when DownArrow do_something end end end Or have an event class with which you can make a method and assign a handle to it, like so: class MyGameWindow < Framework::GameWindow def initialize key_down.add_handler(method(:do_something)) end def do_something puts "blah blah" end end Please give your views, which do you think would be better in a game developement area, and thanks in advance, ell.

    Read the article

  • Overriding events of excel sheet using VBA

    - by Rashmi Pandit
    Hi, I need to programmatically override the following events of a worksheet: BeforeDoubleClick SelectionChange BeforeRightClick I have been able to override the OnActivate event using the following code: sheet.OnSheetActivate = "MyOwn_Activate" Private Sub MyOwn_Activate() myForm.Show End Sub I have implemented BeforeDoubleClick on similar lines: sheet.OnDoubleClick = "My_BeforeDoubleClick" Private Sub My_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) ... End Sub However, an 'argument not optional' error is thrown at run-time when user double clicks a cell on the sheet. Can someone please suggest how should I pass the paramters? In addition, I am not able to find event names for SelectionChange & BeforeRightClick. I tried: sheet.BeforeRightClick = "My_BeforeRightClick" sheet.SelectionChange = "My_SelectionChange" But, both the above lines do not work. Any help/ suggestion is greatly appreciated. Thanks :)

    Read the article

< Previous Page | 63 64 65 66 67 68 69 70 71 72 73 74  | Next Page >