示例#1
0
        public static CFProxy[] GetProxiesForAutoConfigurationScript(NSString proxyAutoConfigurationScript, NSUrl targetURL)
        {
            if (proxyAutoConfigurationScript == null)
                throw new ArgumentNullException ("proxyAutoConfigurationScript");

            if (targetURL == null)
                throw new ArgumentNullException ("targetURL");

            NSArray array = CopyProxiesForAutoConfigurationScript (proxyAutoConfigurationScript, targetURL);

            if (array == null)
                return null;

            NSDictionary[] dictionaries = NSArray.ArrayFromHandle<NSDictionary> (array.Handle);
            array.Dispose ();

            if (dictionaries == null)
                return null;

            CFProxy[] proxies = new CFProxy [dictionaries.Length];
            for (int i = 0; i < dictionaries.Length; i++)
                proxies[i] = new CFProxy (dictionaries[i]);

            return proxies;
        }
示例#2
0
        public HyperLink(string pretext, string text, string postext, string address, string style)
            : base()
        {
            this.url = new NSUrl (address);

            AllowsEditingTextAttributes = true;
            Bordered        = false;
            DrawsBackground = false;
            Editable        = false;
            Selectable      = false;
            base.Font = NSFontManager.SharedFontManager.FontWithFamily (
                "Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

            NSData name_data = NSData.FromString (pretext+"<a href='" + this.url +
                                                  "' "+style+" >" + text + "</a>"+postext);

            NSDictionary name_dictionary       = new NSDictionary();
            NSAttributedString name_attributes = new NSAttributedString (name_data, new NSUrl ("file://"), out name_dictionary);

            NSMutableAttributedString s = new NSMutableAttributedString ();
            s.Append (name_attributes);

            Cell.AttributedStringValue = s;

            SizeToFit ();
        }
示例#3
0
        public ImageViewItem(string file, bool isVideo)
        {
            File = file;
            Url = new NSUrl(File, false);

            IsVideo = isVideo;
        }
示例#4
0
        public static AVAudioRecorder ToUrl(NSUrl url, AVAudioRecorderSettings settings, out NSError error)
        {
            if (settings == null)
                throw new ArgumentNullException ("settings");

            return ToUrl (url, settings.ToDictionary (), out error);
        }
		public ProductBrowserItem (Product product)
		{
			_url = NSUrl.FromString (product.ImageUrl);
			_product = product;

			GetUrl ();
		}
示例#6
0
 public SystemSound(NSUrl fileUrl)
 {
     var error = AudioServicesCreateSystemSoundID (fileUrl.Handle, out soundId);
     if (error != AudioServiceErrors.None)
         throw new InvalidOperationException (string.Format ("Could not create system sound ID for url {0}; error={1}",
                     fileUrl, error));
     ownsHandle = true;
 }
示例#7
0
		public static ExtAudioFile GetExtAudioFile (NSUrl url, out AudioStreamBasicDescription audioDescription)
		{
			// Notice the following line that we can not pass a NSUrl to a CFUrl
			//ExtAudioFile ext = ExtAudioFile.OpenUrl(url);

			// Basic Descriptions
			AudioStreamBasicDescription fileFormat;
			AudioStreamBasicDescription outputFormat;

			// So now we create a CFUrl
			CFUrl curl = CFUrl.FromFile (url.Path);

			// Open the file
			ExtAudioFile ext = ExtAudioFile.OpenUrl (curl);

			// Get the audio format
			fileFormat = ext.FileDataFormat;

			// Don't know how to handle sounds with more than 2 channels (i.e. stereo)
			// Remember that OpenAL sound effects must be mono to be spatialized anyway.
			if (fileFormat.ChannelsPerFrame > 2) {
#if DEBUG				
				Console.WriteLine ("Unsupported Format: Channel count [0] is greater than stereo.", fileFormat.ChannelsPerFrame);
#endif
                audioDescription = new AudioStreamBasicDescription();
				return null;
			}

			// The output format must be linear PCM because that's the only type OpenAL knows how to deal with.
			// Set the client format to 16 bit signed integer (native-endian) data because that is the most
			// optimal format on iPhone/iPod Touch hardware.
			// Maintain the channel count and sample rate of the original source format.
			outputFormat = new AudioStreamBasicDescription ();	// Create our output format description to be converted to
			outputFormat.SampleRate = fileFormat.SampleRate;	// Preserve the original sample rate
			outputFormat.ChannelsPerFrame = fileFormat.ChannelsPerFrame;	// Preserve the orignal number of channels
			outputFormat.Format = AudioFormatType.LinearPCM;	// We want Linear PCM

			// IsBigEndian is causing some problems with distorted sounds on MacOSX
//			outputFormat.FormatFlags = AudioFormatFlags.IsBigEndian
//							| AudioFormatFlags.IsPacked
//							| AudioFormatFlags.IsSignedInteger;
			
			outputFormat.FormatFlags = AudioFormatFlags.IsPacked
							| AudioFormatFlags.IsSignedInteger;
			outputFormat.FramesPerPacket = 1;	// We know for linear PCM, the definition is 1 frame per packet
			outputFormat.BitsPerChannel = 16;	// We know we want 16-bit
			outputFormat.BytesPerPacket = 2 * outputFormat.ChannelsPerFrame;	// We know we are using 16-bit, so 2-bytes per channel per frame
			outputFormat.BytesPerFrame = 2 * outputFormat.ChannelsPerFrame;		// For PCM, since 1 frame is 1 packet, it is the same as mBytesPerPacket

			// Set the desired client (output) data format
			ext.ClientDataFormat = outputFormat;

			// Copy the output format to the audio description that was passed in so the
			// info will be returned to the user.
			audioDescription = outputFormat;

			return ext;
		}
示例#8
0
        public override void AwakeFromNib ()
        {
            base.AwakeFromNib ();

            this.AddressLabel.StringValue = Properties_Resources.EnterWebAddress;
            this.UserLabel.StringValue = Properties_Resources.User + ": ";
            this.PasswordLabel.StringValue = Properties_Resources.Password + ": ";

            this.AddressDelegate = new TextFieldDelegate();
            this.AddressText.Delegate = this.AddressDelegate;
            this.UserDelegate = new TextFieldDelegate();
            this.UserText.Delegate = this.UserDelegate;
            this.PasswordDelegate = new TextFieldDelegate();
            this.PasswordText.Delegate = this.PasswordDelegate;

            this.ContinueButton.Title = Properties_Resources.Continue;
            this.CancelButton.Title = Properties_Resources.Cancel;

            this.AddressText.StringValue = (Controller.PreviousAddress == null || String.IsNullOrEmpty (Controller.PreviousAddress.ToString ())) ? "https://" : Controller.PreviousAddress.ToString ();
            this.UserText.StringValue = String.IsNullOrEmpty (Controller.saved_user) ? Environment.UserName : Controller.saved_user;
            //            this.PasswordText.StringValue = String.IsNullOrEmpty (Controller.saved_password) ? "" : Controller.saved_password;
            this.PasswordText.StringValue = "";


            // Cmis server address help link
            string helpLabel = Properties_Resources.Help + ": ";
            string helpLink = Properties_Resources.WhereToFind;
            string addressUrl = @"https://github.com/aegif/CmisSync/wiki/What-address";
            this.AddressHelp.AllowsEditingTextAttributes = true;
            this.AddressHelp.Selectable = true;           
            var attrStr = new NSMutableAttributedString(helpLabel + helpLink);
            var labelRange = new NSRange(0, helpLabel.Length);
            var linkRange = new NSRange(helpLabel.Length, helpLink.Length);
            var url = new NSUrl(addressUrl);
            var font = this.AddressHelp.Font;
            var paragraph = new NSMutableParagraphStyle()
            {
                LineBreakMode = this.AddressHelp.Cell.LineBreakMode,
                Alignment = this.AddressHelp.Alignment
            };
            attrStr.BeginEditing();
            attrStr.AddAttribute(NSAttributedString.LinkAttributeName, url, linkRange);
            attrStr.AddAttribute(NSAttributedString.ForegroundColorAttributeName, NSColor.Blue, linkRange);
            attrStr.AddAttribute(NSAttributedString.ForegroundColorAttributeName, NSColor.Gray, labelRange);
            attrStr.AddAttribute(NSAttributedString.UnderlineStyleAttributeName, new NSNumber(1), linkRange);
            attrStr.AddAttribute(NSAttributedString.FontAttributeName, font, new NSRange(0, attrStr.Length));
            attrStr.AddAttribute(NSAttributedString.ParagraphStyleAttributeName, paragraph, new NSRange(0, attrStr.Length));
            attrStr.EndEditing();
            this.AddressHelp.AttributedStringValue = attrStr;

            InsertEvent ();

            //  Must be called after InsertEvent()
            CheckTextFields ();
        }
示例#9
0
		static void PrepareCache ()
		{
			MonodocDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Library/Caches/MacDoc/");
			var mdocimages = Path.Combine (MonodocDir, "mdocimages");
			MonodocBaseUrl = new NSUrl (MonodocDir);
			if (!Directory.Exists (mdocimages)){
				try {
					Directory.CreateDirectory (mdocimages);
				} catch {}
			}
		}
示例#10
0
		public static NSError RegisterFontsForUrl (NSUrl fontUrl, CTFontManagerScope scope)
		{
			if (fontUrl == null)
				throw new ArgumentNullException ("fontUrl");
			
			NSError e = new NSError (ErrorDomain, 0);

			if (CTFontManagerRegisterFontsForURL (fontUrl.Handle, scope, e.Handle))
				return null;
			else
				return e;
		}
示例#11
0
        public override WindowResponse Show()
        {
            WindowResponse resp;
            List<string> filetypes = new List<string>();
            NSUrl initDir = null;
            if (Directory.Exists(InitialDirectory)) initDir = new NSUrl(InitialDirectory);

            switch(DialogType)
            {
                case FileDialogType.OpenFile:
                    ofdlg = new NSOpenPanel();
                    if (initDir != null) ofdlg.DirectoryUrl = initDir;
                    ofdlg.Title = Title;
                    ofdlg.CanChooseFiles = true;
                    ofdlg.CanChooseDirectories = false;
                    ofdlg.AllowsMultipleSelection = false;
                    if(filetypes.Count > 0)
                    {
                        foreach(FileTypeFilter arr in FileTypeFilters) filetypes.AddRange(arr.Filter);
                        ofdlg.AllowedFileTypes = filetypes.ToArray();
                    }

                    resp = CocoaHelper.GetResponse(ofdlg.RunModal());
                    SelectedPath = ofdlg.Url.Path;
                    return resp;

                case FileDialogType.SelectFolder:
                    ofdlg = new NSOpenPanel();
                    if (initDir != null) ofdlg.DirectoryUrl = initDir;
                    ofdlg.Title = Title;
                    ofdlg.CanChooseFiles = false;
                    ofdlg.CanChooseDirectories = true;
                    ofdlg.AllowsMultipleSelection = false;

                    resp = CocoaHelper.GetResponse(ofdlg.RunModal());
                    SelectedPath = ofdlg.Url.Path;
                    return resp;

                case FileDialogType.SaveFile:
                    sfdlg = new NSSavePanel();
                    if (initDir != null) sfdlg.DirectoryUrl = initDir;
                    sfdlg.Title = Title;
                    sfdlg.CanCreateDirectories = true;

                    resp = CocoaHelper.GetResponse(sfdlg.RunModal());
                    SelectedPath = sfdlg.Url.Path;
                    return resp;
            }

            return WindowResponse.None;
        }
示例#12
0
		public override bool ReadFromUrl (NSUrl url, string typeName, out NSError outError)
		{
			Console.WriteLine ("ReadFromUrl : {0}", url.ToString ());
			outError = null;

			// if scheme is not right, we ignore the url
			if (url.Scheme != "monodoc" && url.Scheme != "mdoc")
				return true;
			
			// ResourceSpecifier is e.g. "//T:System.String"
			initialLoadFromUrl = Uri.UnescapeDataString (url.ResourceSpecifier.Substring (2));
			this.FileUrl = url;
			
			return true;
		}
示例#13
0
        public static AVAudioPlayer FromUrl(NSUrl url, out NSError error)
        {
            unsafe {
                IntPtr errhandle;
                IntPtr ptrtohandle = (IntPtr) (&errhandle);

                var ap = new AVAudioPlayer (url, ptrtohandle);
                if (ap.Handle == IntPtr.Zero){
                    error = (NSError) Runtime.GetNSObject (errhandle);
                    return null;
                } else
                    error = null;
                return ap;
            }
        }
示例#14
0
        public static AVAudioRecorder ToUrl(NSUrl url, NSDictionary settings, out NSError error)
        {
            unsafe {
                IntPtr errhandle;
                IntPtr ptrtohandle = (IntPtr) (&errhandle);

                var ap = new AVAudioRecorder (url, settings, ptrtohandle);
                if (ap.Handle == IntPtr.Zero){
                    error = (NSError) Runtime.GetNSObject (errhandle);
                    return null;
                } else
                    error = null;
                return ap;
            }
        }
示例#15
0
        public static CGImage Create(NSUrl url, SizeF maxThumbnailSize, float scaleFactor = 1, bool iconMode = false)
        {
            NSMutableDictionary dictionary = null;

            if (scaleFactor != 1 && iconMode != false) {
                dictionary = new NSMutableDictionary ();
                dictionary.LowlevelSetObject ((NSNumber) scaleFactor, OptionScaleFactorKey.Handle);
                dictionary.LowlevelSetObject (iconMode ? CFBoolean.True.Handle : CFBoolean.False.Handle, OptionIconModeKey.Handle);
            }

            var handle = QLThumbnailImageCreate (IntPtr.Zero, url.Handle, maxThumbnailSize, dictionary == null ? IntPtr.Zero : dictionary.Handle);
            GC.KeepAlive (dictionary);
            if (handle != null)
                return new CGImage (handle, true);

            return null;
        }
示例#16
0
		public override bool ReadFromUrl (NSUrl url, string typeName, out NSError outError)
		{
			Console.WriteLine ("ReadFromUrl : {0}", url.ToString ());
			outError = null;
			const int NSServiceMiscellaneousError = 66800;
			if (url.Scheme != "monodoc" && url.Scheme != "mdoc") {
				outError = new NSError (NSError.CocoaErrorDomain,
				                       	NSServiceMiscellaneousError,
				                      	NSDictionary.FromObjectAndKey (NSError.LocalizedFailureReasonErrorKey, new NSString (string.Format ("Scheme {0} isn't supported", url.Scheme))));
				return false;
			}
			
			// ResourceSpecifier is e.g. "//T:System.String"
			initialLoadFromUrl = Uri.UnescapeDataString (url.ResourceSpecifier.Substring (2));
			this.FileUrl = url;
			
			return true;
		}
示例#17
0
        public SparkleAlert()
            : base()
        {
            MessageText     = "SparkleShare couldn't find Git on your system. Do you want to download it?";
            InformativeText = "Git is required to run SparkleShare.";

            Icon = NSImage.ImageNamed ("sparkleshare.icns");

            AddButton ("Download");
            AddButton ("Cancel");

            Buttons [0].Activated += delegate {
                NSUrl url = new NSUrl ("http://code.google.com/p/git-osx-installer/downloads/list");
                NSWorkspace.SharedWorkspace.OpenUrl (url);
                Environment.Exit (0);
            };

            Buttons [1].Activated += delegate {
                Environment.Exit (-1);
            };
        }
示例#18
0
		public override bool ReadFromUrl (NSUrl url, string typeName, out NSError outError)
		{
			fsEvents = new FSEventStream (new [] { Path.GetDirectoryName (url.Path) },
				TimeSpan.FromSeconds (0), FSEventStreamCreateFlags.FileEvents);

			fsEvents.Events += (sender, e) => {
				foreach (var evnt in e.Events) {
					if (evnt.Path == url.Path && (evnt.Flags & FSEventStreamEventFlags.ItemModified) != 0) {
						ReloadDocument ();
						break;
					}
				}
			};

			fsEvents.ScheduleWithRunLoop (NSRunLoop.Current);
			fsEvents.Start ();

			documentUrl = url;
			outError = null;
			return true;
		}
示例#19
0
		public override bool WriteToUrl (NSUrl absoluteUrl, string typeName, NSSaveOperationType saveOperation, NSUrl absoluteOriginalContentsUrl, out NSError outError)
		{
			var saveOptions = new QTMovieSaveOptions () {
				Flatten = true
			};
			return movie.SaveTo (absoluteUrl.Path, new QTMovieSaveOptions () { Flatten = true }, out outError);
		}
		public static CFRunLoopSource ExecuteProxyAutoConfigurationURL (NSUrl proxyAutoConfigurationURL, NSUrl targetURL, CFProxyAutoConfigurationResultCallback resultCallback, CFStreamClientContext clientContext)
		{
			if (proxyAutoConfigurationURL == null)
				throw new ArgumentNullException ("proxyAutoConfigurationURL");

			if (targetURL == null)
				throw new ArgumentNullException ("targetURL");

			if (resultCallback == null)
				throw new ArgumentNullException ("resultCallback");

			if (clientContext == null)
				throw new ArgumentNullException ("clientContext");

			IntPtr source = CFNetworkExecuteProxyAutoConfigurationURL (proxyAutoConfigurationURL.Handle, targetURL.Handle, resultCallback, clientContext);

			if (source != IntPtr.Zero)
				return new CFRunLoopSource (source);

			return null;
		}
		public static CFProxy[] GetProxiesForURL (NSUrl url, CFProxySettings proxySettings)
		{
			if (url == null || (url.Handle == IntPtr.Zero))
				throw new ArgumentNullException ("url");
			
			if (proxySettings == null)
				proxySettings = GetSystemProxySettings ();
			
			NSArray array = CopyProxiesForURL (url, proxySettings.Dictionary);
			
			if (array == null)
				return null;
			
			NSDictionary[] dictionaries = NSArray.ArrayFromHandle<NSDictionary> (array.Handle);
			array.Dispose ();
			
			if (dictionaries == null)
				return null;
			
			CFProxy[] proxies = new CFProxy [dictionaries.Length];
			for (int i = 0; i < dictionaries.Length; i++)
				proxies[i] = new CFProxy (dictionaries[i]);
			
			return proxies;
		}
		static NSArray CopyProxiesForURL (NSUrl url, NSDictionary proxySettings)
		{
			IntPtr native = CFNetworkCopyProxiesForURL (url.Handle, proxySettings != null ? proxySettings.Handle : IntPtr.Zero);
			
			if (native == IntPtr.Zero)
				return null;
			
			return new NSArray (native);
		}
		public static CFProxy[] GetProxiesForAutoConfigurationScript (NSString proxyAutoConfigurationScript, Uri targetUri)
		{
			if (proxyAutoConfigurationScript == null)
				throw new ArgumentNullException ("proxyAutoConfigurationScript");
			
			if (targetUri == null)
				throw new ArgumentNullException ("targetUri");
			
			NSUrl targetURL = new NSUrl (targetUri.AbsoluteUri);
			CFProxy[] proxies = GetProxiesForAutoConfigurationScript (proxyAutoConfigurationScript, targetURL);
			targetURL.Dispose ();
			
			return proxies;
		}
		static NSArray CopyProxiesForAutoConfigurationScript (NSString proxyAutoConfigurationScript, NSUrl targetURL)
		{
			IntPtr native = CFNetworkCopyProxiesForAutoConfigurationScript (proxyAutoConfigurationScript.Handle, targetURL.Handle);
			
			if (native == IntPtr.Zero)
				return null;
			
			return new NSArray (native);
		}
示例#25
0
        public static CFProxy[] GetProxiesForUri(Uri uri, CFProxySettings proxySettings)
        {
            if (uri == null)
                throw new ArgumentNullException ("uri");

            NSUrl url = new NSUrl (uri.AbsoluteUri);
            CFProxy[] proxies = GetProxiesForURL (url, proxySettings);
            url.Dispose ();

            return proxies;
        }
示例#26
0
 public override string[] FilesDropped(NSTableView tableView, MonoMac.Foundation.NSUrl dropDestination, MonoMac.Foundation.NSIndexSet indexSet)
 {
     return(new string [0]);
 }
示例#27
0
		/**
		 * Returns a byte buffer containing all the pcm data.
		 */
		public static byte[] GetOpenALAudioDataAll (NSUrl file_url, out int dataBufferSize, out ALFormat alFormat, out double sampleRate, out double duration)
		{

			long fileLengthInFrames = 0;
			AudioStreamBasicDescription outputFormat;
			int maxBufferSize;
			byte[] pcmData;
			dataBufferSize = 0;
			alFormat = 0;
			sampleRate = 0;
			duration = 0;

			ExtAudioFile extFile;

			try {
				extFile = GetExtAudioFile (file_url, out outputFormat);
			} catch (Exception extExc) {
#if DEBUG				
				Console.WriteLine ("ExtAudioFile.OpenUrl failed, Error : " + extExc.Message);
#endif
				return null;
			}

			/* Get the total frame count */
			try {
				fileLengthInFrames = extFile.FileLengthFrames;
			} catch (Exception exc) {
#if DEBUG				
				Console.WriteLine ("ExtAudioFile.FileLengthFranes failed, Error : " + exc.Message);
#endif
				return null;
			}

			/* Compute the number of bytes needed to hold all the data in the file. */
			maxBufferSize = (int)(fileLengthInFrames * outputFormat.BytesPerFrame);
			/* Allocate memory to hold all the decoded PCM data. */
			pcmData = new byte[maxBufferSize];

			bool gotData = GetDataFromExtAudioFile (extFile, outputFormat, maxBufferSize, pcmData,
			                        out dataBufferSize, out alFormat, out sampleRate);

			if (!gotData) {
				pcmData = null;
			}

			duration = (dataBufferSize / ((outputFormat.BitsPerChannel / 8) * outputFormat.ChannelsPerFrame)) / outputFormat.SampleRate;

			// we probably should make sure the buffer sizes are in accordance.
			//	assert(maxBufferSize == dataBufferSize);

			// We do not need the ExtAudioFile so we will set it to null
			extFile = null;
			return pcmData;

		}
示例#28
0
        private void CreateAbout()
        {
            Box = new NSBox () {
                FillColor = NSColor.White,
                Frame = new RectangleF (-1, Frame.Height - 105, Frame.Width + 2, 105),
                BoxType = NSBoxType.NSBoxCustom
            };

            HeaderTextField = new NSTextField () {
                StringValue     = "SparkleShare",
                Frame           = new RectangleF (22, Frame.Height - 89, 318, 48),
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Condensed, 0, 24)
            };

            VersionTextField = new NSTextField () {
                StringValue     = Defines.VERSION,
                Frame           = new RectangleF (22, Frame.Height - 94, 318, 22),
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                TextColor       = NSColor.DisabledControlText
            };

            UpdatesTextField = new NSTextField () {
                StringValue     = "Checking for updates...",
                Frame           = new RectangleF (22, Frame.Height - 222, 318, 98),
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                TextColor       = NSColor.DisabledControlText
            };

            CreditsTextField = new NSTextField () {
                StringValue     = @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others" +
                                   "\n" +
                                   "\n" +
                                   "SparkleShare is Free and Open Source Software. You are free to use, modify, and redistribute it " +
                                   "under the GNU General Public License version 3 or later.",
                Frame           = new RectangleF (22, Frame.Height - 250, 318, 98),
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
            };

            WebsiteButton = new NSButton () {
                Frame = new RectangleF (12, 12, 120, 32),
                Title = "Visit Website",
                BezelStyle = NSBezelStyle.Rounded,
                Font = SparkleUI.Font
            };

            WebsiteButton.Activated += delegate {

                NSUrl url = new NSUrl ("http://www.sparkleshare.org/");
                NSWorkspace.SharedWorkspace.OpenUrl (url);

            };

            CreditsButton = new NSButton () {
                Frame = new RectangleF (Frame.Width - 12 - 120, 12, 120, 32),
                Title = "Show Credits",
                BezelStyle = NSBezelStyle.Rounded,
                Font = SparkleUI.Font
            };

            CreditsButton.Activated += delegate {

                NSUrl url = new NSUrl ("http://www.sparkleshare.org/credits/");
                NSWorkspace.SharedWorkspace.OpenUrl (url);

            };

            ContentView.AddSubview (Box);
            ContentView.AddSubview (HeaderTextField);
            ContentView.AddSubview (VersionTextField);
            ContentView.AddSubview (UpdatesTextField);
            ContentView.AddSubview (CreditsTextField);
            ContentView.AddSubview (CreditsButton);
            ContentView.AddSubview (WebsiteButton);
        }
        public void ExportEveryGlyphsAsPNGTo(string path)
        {
            float scale = Window.BackingScaleFactor;
            var glyphInfos = _tableViewSource.GlyphInfos;
            //actvw.StartAnimating ();
            Task.Factory.StartNew (() => {
                Func<string, string> makeName = (rawName) => {
                    return String.Format ("{0}_{1}{2}.png", rawName, (int)this.unitFontSize
                                          , ((scale > 2f) ? "@4x" : (scale > 1f) ? "@2x" : ""));
                };
                //string documentDirPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
                string documentDirPath = path;

                NSDictionary prop = new NSDictionary (); //
                int nSucceeded = 0;
                int nFailed = 0;
                glyphInfos.ForEach ((gi) => {
                    var url = new NSUrl (System.IO.Path.Combine (documentDirPath, makeName (gi.RawName)), false);
                    try {
                        CGImageDestination dest = CGImageDestination.FromUrl (url, "public.png", 1);
                        dest.AddImage (gi.GlyphImage, prop);
                        dest.Close ();
                    }
                    catch (Exception ex) {
                        Console.WriteLine (ex.ToString ());
                    }
                    if (System.IO.File.Exists (url.Path)) {
                        //Console.WriteLine ("Succeeded to write {0}", url);
                        ++ nSucceeded;
                    }
                    else {
                        Console.WriteLine ("Failed to write {0}", url);
                        ++ nFailed;
                    }
                    BeginInvokeOnMainThread (() => {
                        //ShowProgressionLabel (String.Format ("{0} of {1} processed", (nSucceeded + nFailed), glyphInfos.Count));
                    });
                });

                InvokeOnMainThread (() => {
                    //actvw.StopAnimating ();
                    //DismissProgressionLabel ();
                    var alert = new NSAlert ();
                    alert.MessageText = String.Format ("{0} succeeded, {1} failed", nSucceeded, nFailed);
                    alert.RunModal ();
                });
            });
        }
示例#30
0
        public static CGImageSource CreateWithURL(NSUrl url, NSDictionary options)
        {
            if (url == null)
                throw new ArgumentNullException ("url");

            return new CGImageSource (CGImageSourceCreateWithURL (url.Handle, options == null ? IntPtr.Zero : options.Handle));
        }
示例#31
0
		public override bool ReadFromUrl (NSUrl absoluteUrl, string typeName, out NSError outError)
		{
			var loaded = QTMovie.FromUrl (absoluteUrl, out outError);
			if (loaded != null){
				loaded.SetAttribute (NSNumber.FromBoolean (true), QTMovie.EditableAttribute);
				
				if (movie != null)
					movie.Dispose ();
				movie = loaded;
			}
			return loaded != null;
		}