当前位置: 首页>>代码示例>>C#>>正文


C# Foundation.NSUrl类代码示例

本文整理汇总了C#中MonoMac.Foundation.NSUrl的典型用法代码示例。如果您正苦于以下问题:C# NSUrl类的具体用法?C# NSUrl怎么用?C# NSUrl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NSUrl类属于MonoMac.Foundation命名空间,在下文中一共展示了NSUrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HyperLink

        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 ();
        }
开发者ID:greenqloud,项目名称:qloudsync,代码行数:26,代码来源:HyperLink.cs

示例2: GetProxiesForAutoConfigurationScript

        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;
        }
开发者ID:jacksonh,项目名称:maccore,代码行数:25,代码来源:CFProxySupport.cs

示例3: ImageViewItem

        public ImageViewItem(string file, bool isVideo)
        {
            File = file;
            Url = new NSUrl(File, false);

            IsVideo = isVideo;
        }
开发者ID:kevintavog,项目名称:MapThis,代码行数:7,代码来源:ImageViewItem.cs

示例4: ToUrl

        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);
        }
开发者ID:jorik041,项目名称:maccore,代码行数:7,代码来源:AVAudioRecorder.cs

示例5: ProductBrowserItem

		public ProductBrowserItem (Product product)
		{
			_url = NSUrl.FromString (product.ImageUrl);
			_product = product;

			GetUrl ();
		}
开发者ID:robertmiles3,项目名称:xamarin-store-app,代码行数:7,代码来源:ProductBrowserItem.cs

示例6: SystemSound

 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;
 }
开发者ID:kangaroo,项目名称:maccore,代码行数:8,代码来源:SystemSound.cs

示例7: GetExtAudioFile

		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;
		}
开发者ID:KennethYap,项目名称:MonoGame,代码行数:58,代码来源:OpenALSupport.cs

示例8: AwakeFromNib

        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 ();
        }
开发者ID:emrul,项目名称:CmisSync,代码行数:55,代码来源:SetupSubLoginController.cs

示例9: PrepareCache

		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 {}
			}
		}
开发者ID:kangaroo,项目名称:monomac,代码行数:11,代码来源:AppDelegate.cs

示例10: RegisterFontsForUrl

		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;
		}
开发者ID:Anomalous-Software,项目名称:maccore,代码行数:12,代码来源:CTFontManager.cs

示例11: Show

        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;
        }
开发者ID:ivynetca,项目名称:lapsestudio,代码行数:51,代码来源:CocoaFileDialog.cs

示例12: ReadFromUrl

		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;
		}
开发者ID:baulig,项目名称:monomac,代码行数:15,代码来源:MyDocument.cs

示例13: FromUrl

        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;
            }
        }
开发者ID:kangaroo,项目名称:maccore,代码行数:15,代码来源:AVAudioPlayer.cs

示例14: ToUrl

        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;
            }
        }
开发者ID:kangaroo,项目名称:maccore,代码行数:15,代码来源:AVAudioRecorder.cs

示例15: Create

        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;
        }
开发者ID:roblillack,项目名称:maccore,代码行数:17,代码来源:Thumbnail.cs


注:本文中的MonoMac.Foundation.NSUrl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。