Exemplo n.º 1
0
		public static void Main (string[] args)
		{
			//test
			everspaces e = new everspaces("192.168.1.110", 9999);
			//everspaces e = new everspaces();
			
			e.createLinkCompleted += new createLinkHandler(getCreateLinkResult);
			e.getLinkCompleted += new getLinkHandler(getLinkResult);
	
			metadata coord;
			coord.x1 = 0;
			coord.x2 = 5;
			coord.y1 = 0;
			coord.y2 = 5;
			
			slink link = new slink(coord);
			link.setTitle("PLinkWin");
			link.setComment("Testing PLinkWin");
			List<String> tags = new List<String>();
			tags.Add("ryan");
			link.setTags(tags);
			//List<String> files = new List<String>();
			//files.Add("qrcode.jpg");
			//link.setResources(files);
			
			IAsyncResult result;
			
			//Console.WriteLine("Waiting to create...");
			//Thread.Sleep(5000);
			
			e.createLink(link, true);
			
			while(ids.Count == 0){}
			
			e.getLink(ids[0]);
			
			while(l == null){}
			
			metadata m = l.getMetadata();
			Console.WriteLine(m.x1);
			Console.WriteLine(m.y1);
			Console.WriteLine(m.x2);
			Console.WriteLine(m.y2);
			Console.WriteLine(l.getComment());
			Console.WriteLine(l.getAppType());
			Console.WriteLine(l.getUri());
			
			Console.WriteLine("Waiting to open...");
			Thread.Sleep(5000);
			result = e.openLink(l.getNoteGuid());
			
			result.AsyncWaitHandle.WaitOne();
	    }
        public void UploadToEvernote()
        {
            if (galleryStack.Children.Count == 0)
            {
                return;
            }

            if (UploadingBegin != null)
            {
                UploadingBegin(this, EventArgs.Empty);
            }

            slink link = new slink(new metadata());
            link.setTitle("Screen Capture");
            List<string> tags = new List<string>();
            tags.Add("Demo");

            evernoteButton.Visibility = Visibility.Hidden;

            List<Tuple<byte[], string>> resources = new List<Tuple<byte[], string>>();

            foreach (var child in galleryStack.Children)
            {
                SpaceImageButton img = child as SpaceImageButton;
                if (img == null)
                {
                    continue;
                }

                var data = img.Tag as Tuple<byte[], string>;
                if (data == null)
                {
                    continue;
                }

                resources.Add(data);
            }

            link.setResources(resources);

            if (everSpaces != null)
            {
                everSpaces.createLink(link);
            }

            Trace.WriteLine("Uploading to evernote...");
        }
Exemplo n.º 3
0
		public IAsyncResult createLink(slink link, bool upload=false)
		{
			IAsyncResult result;
	  		createLinkDelegate worker = new createLinkDelegate(createLinkWorker);
  			AsyncCallback completedCallback = new AsyncCallback(createLinkCallback);
			
			lock(_createLinkSync)
			{		
				if(_createLinkBusy)
					throw new Exception("Create Link is busy");
				
				AsyncOperation async = AsyncOperationManager.CreateOperation(null);
	    		result = worker.BeginInvoke(link, upload, completedCallback, async);
				_createLinkBusy = true;
			}
			
			return result;
		}
Exemplo n.º 4
0
		protected virtual void OnGetLinkCompleted(slink data) 
		{
			if(getLinkCompleted != null)
    			getLinkCompleted(data);
		}
Exemplo n.º 5
0
		private string createLinkWorker(slink link, bool upload=false)
		{
			string appType = constants.UNKNOWN;
			string uri = constants.UNKNOWN;
			if(_connected)
			{
				appType = appFocusRequest();
				uri = appUriRequest(appType);
			}
			
			link.setAppType(appType);
			link.setUri(uri);
			
            //modified by Wander
            if (appType == constants.APP_APPLE_SAFARI && uri != constants.UNKNOWN)
            {
                Trace.WriteLine("Linked to " + uri);
            }


			if((appType == constants.APP_APPLE_FINDER || appType == constants.APP_WIN_EXPLORER) 
			   	&& uri != constants.UNKNOWN && upload)
			{
				string path;
				string request;
				string identifier;
				
				if(appType == constants.APP_APPLE_FINDER)
				{
					path = Regex.Replace(uri, "file://.*?/", "/");
					request = constants.REQUEST_FINDERUPLOAD;
					identifier = constants.IDENTIFIER_FINDERUPLOAD;
				}
				else
				{
					path = uri;
					request = constants.REQUEST_EXPLORERUPLOAD;
					identifier = constants.IDENTIFIER_EXPLORERUPLOAD;
				}
				
				Dictionary<string, object> dataMap = new Dictionary<string, object>();
				Dictionary<string, object> map = new Dictionary<string, object>();
				string jsonObject;
				
				dataMap.Add(identifier, path);
				map.Add("TYPE", request);
				map.Add("DATA", dataMap);
			
				Console.WriteLine ("Requesting: {0}", request);
				jsonObject = JsonConvert.SerializeObject(map);
				s.write(jsonObject + "\r");
				
				string textData = s.readData();
				byte[] data = System.Text.Encoding.Unicode.GetBytes(textData);
				string extension = Path.GetExtension(path);
				string mime = slink.getMimeType(extension);
				link.addResource(data, mime);
			}
			
			return spaces.createNote(link);
		}
Exemplo n.º 6
0
		private static void getLinkResult(slink link)
		{
			l = link;
		}