Пример #1
0
        public void Pick(Action <string, MediaResult[]> callback)
        {
            Util.NullArgumentTest(callback);

            if (mPickerController != null)
            {
                Debug.Log("Ignoring Pick call because another image picker UI is being shown.");
                return;
            }

            callback = RuntimeHelper.ToMainThread(callback);

            // Create a new image picker.
            var picker = InteropObjectFactory <UIImagePickerController> .Create(
                () => new UIImagePickerController(),
                c => c.ToPointer());

            // Source type must be photo library.
            picker.SourceType = UIImagePickerController.SourceTypeEnum.PhotoLibrary;

            // Allow image & video.
            NSMutableArray <NSString> mediaTypes = new NSMutableArray <NSString>();

            mediaTypes.AddObject(UTTypeConstants.kUTTypeImage);
            mediaTypes.AddObject(UTTypeConstants.kUTTypeMovie);
            picker.MediaTypes = mediaTypes;

            // Create a delegate for the TBM VC.
            picker.Delegate = new InternalUIImagePickerControllerDelegate(InternalUIImagePickerControllerDelegate.PickerOperation.PickGallery)
            {
                CloseAndResetMatchmakerVC = () =>
                {
                    if (mPickerController != null)
                    {
                        mPickerController.DismissViewController(true, null);
                        mPickerController = null;
                    }
                },
                CompleteCallback = (error, result) =>
                {
                    callback(error, result != null ? new MediaResult[] { result } : null);
                }
            };

            // Store the VC ref.
            mPickerController = picker;

            // Now show the VC.
            using (var unityVC = UIViewController.UnityGetGLViewController())
                unityVC.PresentViewController(picker, true, null);
        }
Пример #2
0
        private void ModelChanged(object sender, EventArgs e)
        {
            // clear existing room list
            iRooms.Release();
            iRooms = new NSMutableArray();

            bool roomsOutOfStandby = false;

            // add current list of rooms
            foreach (Linn.Kinsky.Room room in iModel.Items)
            {
                if (!room.Standby)
                {
                    roomsOutOfStandby = true;
                }
                RoomData data = new RoomData();
                data.SetName(room.Name);

                iRooms.AddObject(data);
                data.Release();
            }

            ButtonStandbyAll.IsEnabled = roomsOutOfStandby;
            ButtonStandbyAll.Image     = roomsOutOfStandby ? Properties.Resources.IconStandbyOn : Properties.Resources.IconStandby;

            // notify that there has been a change in the room list **before** the change in selection
            WillChangeValueForKey(NSString.StringWithUTF8String("rooms"));
            DidChangeValueForKey(NSString.StringWithUTF8String("rooms"));

            WillChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
            DidChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
        }
Пример #3
0
        public void TakePicture(CameraType cameraType, Action <string, MediaResult> callback)
        {
            Util.NullArgumentTest(callback);

            if (mPickerController != null)
            {
                Debug.Log("Ignoring TakePicture call because another image picker UI is being shown.");
                return;
            }

            callback = RuntimeHelper.ToMainThread(callback);

            if (!IsCameraAvailable(cameraType))
            {
                callback(cameraType.ToString() + " camera is not supported on this device.", null);
                return;
            }

            // Create a new image picker.
            var picker = InteropObjectFactory <UIImagePickerController> .Create(
                () => new UIImagePickerController(),
                c => c.ToPointer());

            // Source type must be camera.
            picker.SourceType = UIImagePickerController.SourceTypeEnum.Camera;

            // Set camera type.
            picker.CameraDevice = cameraType == CameraType.Front ? UIImagePickerController.CameraDeviceEnum.Front : UIImagePickerController.CameraDeviceEnum.Rear;

            // Only allow image.
            NSMutableArray <NSString> mediaTypes = new NSMutableArray <NSString>();

            mediaTypes.AddObject(UTTypeConstants.kUTTypeImage);
            picker.MediaTypes = mediaTypes;

            // Create a delegate for the TBM VC.
            picker.Delegate = new InternalUIImagePickerControllerDelegate(InternalUIImagePickerControllerDelegate.PickerOperation.TakePicture)
            {
                CloseAndResetVC = () =>
                {
                    if (mPickerController != null)
                    {
                        mPickerController.DismissViewController(true, null);
                        mPickerController = null;
                    }
                },
                CompleteCallback = (error, result) =>
                {
                    callback(error, result);
                }
            };

            // Store the VC ref.
            mPickerController = picker;

            // Now show the VC.
            using (var unityVC = UIViewController.UnityGetGLViewController())
                unityVC.PresentViewController(picker, true, null);
        }
Пример #4
0
        private NSArray <NSString> GetPropertyKeys()
        {
            NSMutableArray <NSString> result = new NSMutableArray <NSString>();

            result.AddObject(Constants.CNContactIdentifierKey);
            result.AddObject(Constants.CNContactFamilyNameKey);
            result.AddObject(Constants.CNContactMiddleNameKey);
            result.AddObject(Constants.CNContactGivenNameKey);
            result.AddObject(Constants.CNContactOrganizationNameKey);
            result.AddObject(Constants.CNContactBirthdayKey);
            result.AddObject(Constants.CNContactEmailAddressesKey);
            result.AddObject(Constants.CNContactPhoneNumbersKey);
            result.AddObject(Constants.CNContactImageDataKey);
            return(result);
        }
Пример #5
0
        private void ModelChanged(object sender, EventArgs e)
        {
            iBookmarks.Release();
            iBookmarks = new NSMutableArray();

            foreach (Bookmark b in iBookmarkManager.Bookmarks)
            {
                BookmarkData data = new BookmarkData(b);
                iBookmarks.AddObject(data);
                data.Release();
            }

            WillChangeValueForKey(NSString.StringWithUTF8String("bookmarks"));
            DidChangeValueForKey(NSString.StringWithUTF8String("bookmarks"));
        }
Пример #6
0
        private static NSArray <CNLabeledValue <NSString> > ToCNCotactEmails(KeyValuePair <string, string>[] emails)
        {
            if (emails == null)
            {
                return(null);
            }

            var result = new NSMutableArray <CNLabeledValue <NSString> >();

            foreach (var email in emails)
            {
                NSString label       = NSString.StringWithUTF8String(email.Key);
                NSString nativeEmail = NSString.StringWithUTF8String(email.Value);
                result.AddObject(CNLabeledValue <NSString> .LabeledValueWithLabel(label, nativeEmail));
            }
            return(result);
        }
Пример #7
0
        private static NSArray <CNLabeledValue <CNPhoneNumber> > ToCNContactPhoneNumbers(KeyValuePair <string, string>[] phoneNumbers)
        {
            if (phoneNumbers == null)
            {
                return(null);
            }

            var result = new NSMutableArray <CNLabeledValue <CNPhoneNumber> >();

            foreach (var phoneNumber in phoneNumbers)
            {
                NSString      label  = NSString.StringWithUTF8String(phoneNumber.Key);
                CNPhoneNumber number = CNPhoneNumber.PhoneNumberWithStringValue(phoneNumber.Value);
                result.AddObject(CNLabeledValue <CNPhoneNumber> .LabeledValueWithLabel(label, number));
            }
            return(result);
        }
Пример #8
0
        private void ModelChanged(object sender, EventArgs e)
        {
            // clear existing source list
            iSources.Release();
            iSources = new NSMutableArray();

            // add current list of sources
            foreach (Linn.Kinsky.Source source in iModel.Items)
            {
                SourceData data = new SourceData(source);
                iSources.AddObject(data);
                data.Release();
            }

            // notify that there has been a change in the source list **before** the change in selection
            WillChangeValueForKey(NSString.StringWithUTF8String("sources"));
            DidChangeValueForKey(NSString.StringWithUTF8String("sources"));

            WillChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
            DidChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
        }
Пример #9
0
 public NSArray ToolbarDefaultItemIdentifiers(NSToolbar toolbar)
 {
     NSMutableArray array = new NSMutableArray();
     array.AddObject((NSString) "FontStyle");
     array.AddObject((NSString) "FontSize");
     array.AddObject(NSToolbarItem.NSToolbarSeparatorItemIdentifier);
     array.AddObject((NSString) "BlueLetter");
     array.AddObject(NSToolbarItem.NSToolbarPrintItemIdentifier);
     return array;
 }
Пример #10
0
partial         void CreateAudioDisc(Id sender)
        {
            NSArray files = this.SelectAudioFiles();
            if (files != null)
            {
                NSMutableArray trackList = new NSMutableArray(files.Count);
                foreach (NSString filepath in files.GetEnumerator<NSString>())
                {
                    trackList.AddObject(DRTrack.TrackForAudioFile(filepath));
                }
                this.BurnLayoutWithDescription(trackList, "Burning audio disc");
            }
        }
Пример #11
0
        public NSArray ControlTextViewCompletionsForPartialWordRangeIndexOfSelectedItem(NSControl control, NSTextView textView, NSArray words, NSRange charRange, ref int index)
        {
            NSMutableArray matches;
            NSString partialString;
            NSArray keywords;
            int i;
            uint count;
            NSString str;

            partialString = textView.String.SubstringWithRange(charRange);
            keywords = this.AllKeywords();
            count = keywords.Count;
            matches = new NSMutableArray();

            // find any match in our keyword array against what was typed
            for (i = 0; i < count; i++)
            {
                str = keywords[i].CastTo<NSString>();
                if (str.RangeOfStringOptionsRange(partialString, NSStringCompareOptions.NSAnchoredSearch | NSStringCompareOptions.NSCaseInsensitiveSearch, NSRange.NSMakeRange(0, str.Length)).location != NSUInteger.NSNotFound)
                {
                    matches.AddObject(str);
                }
            }
            matches.SortUsingSelector(ObjectiveCRuntime.Selector("compare:"));

            return matches;
        }
Пример #12
0
        public virtual void AwakeFromNib()
        {
            // If you make sure your dates are calculated at noon, you shouldn't have to
            // worry about daylight savings. If you use midnight, you will have to adjust
            // for daylight savings time.
            NSDate refDate = NSDate.DateWithNaturalLanguageString ("12:00 Oct 27, 2010");
            double oneDay = 24 * 60 * 60;

            // Create graph from theme
            graph = new CPTXYGraph (CGRect.CGRectZero);
            CPTTheme theme = CPTTheme.ThemeNamed (CPTTheme.kCPTDarkGradientTheme);
            graph.ApplyTheme (theme);
            hostView.HostedGraph = graph;

            // Title
            CPTMutableTextStyle textStyle = CPTMutableTextStyle.TextStyle;
            textStyle.Color = CPTColor.WhiteColor;
            textStyle.FontSize = 18.0;
            textStyle.FontName = "Helvetica";
            graph.Title = "Click to Toggle Range Plot Style";
            graph.TitleTextStyle = textStyle;
            graph.TitleDisplacement = new CGPoint (0.0f, -20.0f);

            // Setup scatter plot space
            CPTXYPlotSpace plotSpace = graph.DefaultPlotSpace.CastTo<CPTXYPlotSpace> ();
            double xLow = oneDay * 0.5;
            plotSpace.XRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (xLow), NSDecimal.FromDouble (oneDay * 5.0));
            plotSpace.YRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (1.0), NSDecimal.FromDouble (3.0));

            // Axes
            CPTXYAxisSet axisSet = graph.AxisSet.CastTo<CPTXYAxisSet> ();
            CPTXYAxis x = axisSet.XAxis;
            x.MajorIntervalLength = NSDecimal.FromDouble (oneDay);
            x.OrthogonalCoordinateDecimal = NSDecimal.FromString ("2");
            x.MinorTicksPerInterval = 0;
            NSDateFormatter dateFormatter = new NSDateFormatter ().Autorelease<NSDateFormatter> ();
            dateFormatter.DateStyle = NSDateFormatterStyle.NSDateFormatterShortStyle;
            CPTTimeFormatter timeFormatter = new CPTTimeFormatter (dateFormatter).Autorelease<CPTTimeFormatter> ();
            timeFormatter.ReferenceDate = refDate;
            x.LabelFormatter = timeFormatter;

            CPTXYAxis y = axisSet.YAxis;
            y.MajorIntervalLength = NSDecimal.FromString (@"0.5");
            y.MinorTicksPerInterval = 5;
            y.OrthogonalCoordinateDecimal = NSDecimal.FromDouble (oneDay);

            // Create a plot that uses the data source method
            CPTRangePlot dataSourceLinePlot = new CPTRangePlot ().Autorelease<CPTRangePlot> ();
            dataSourceLinePlot.Identifier = PLOT_IDENTIFIER;

            // Add line style
            CPTMutableLineStyle lineStyle = CPTMutableLineStyle.LineStyle;
            lineStyle.LineWidth = 1.0;
            lineStyle.LineColor = CPTColor.GreenColor;
            barLineStyle = lineStyle.Retain<CPTLineStyle> ();
            dataSourceLinePlot.BarLineStyle = barLineStyle;

            // Bar properties
            dataSourceLinePlot.BarWidth = 10.0;
            dataSourceLinePlot.GapWidth = 20.0;
            dataSourceLinePlot.GapHeight = 20.0;
            dataSourceLinePlot.DataSource = this;

            // Add plot
            graph.AddPlot (dataSourceLinePlot);
            graph.DefaultPlotSpace.Delegate = this;

            // Store area fill for use later
            CPTColor transparentGreen = CPTColor.GreenColor.ColorWithAlphaComponent (0.2);
            areaFill = new CPTFill (transparentGreen);

            // Add some data
            NSMutableArray newData = new NSMutableArray();
            NSUInteger i;
            Random rand = new Random ();
            for (i = 0; i < 5; i++) {
                double xx = oneDay * (i + 1.0);
                double yy = 3.0 * rand.Next () / (double)Int32.MaxValue + 1.2;
                double rHigh = rand.Next () / (double)Int32.MaxValue * 0.5 + 0.25;
                double rLow = rand.Next () / (double)Int32.MaxValue * 0.5 + 0.25;
                double rLeft = (rand.Next () / (double)Int32.MaxValue * 0.125 + 0.125) * oneDay;
                double rRight = (rand.Next () / (double)Int32.MaxValue * 0.125 + 0.125) * oneDay;

                newData.AddObject (NSDictionary.DictionaryWithObjectsAndKeys (
                                                                              NSDecimalNumber.NumberWithDouble (xx), CPTRangePlot.FieldX,
                                                                              NSDecimalNumber.NumberWithDouble (yy), CPTRangePlot.FieldY,
                                                                              NSDecimalNumber.NumberWithDouble (rHigh), CPTRangePlot.FieldHigh,
                                                                              NSDecimalNumber.NumberWithDouble (rLow), CPTRangePlot.FieldLow,
                                                                              NSDecimalNumber.NumberWithDouble (rLeft), CPTRangePlot.FieldLeft,
                                                                              NSDecimalNumber.NumberWithDouble (rRight), CPTRangePlot.FieldRight,
                                                                              null));
            }

            plotData = newData;
        }
Пример #13
0
        public virtual void AwakeFromNib()
        {
            // If you make sure your dates are calculated at noon, you shouldn't have to
            // worry about daylight savings. If you use midnight, you will have to adjust
            // for daylight savings time.
            NSDate refDate = NSDate.DateWithNaturalLanguageString ("12:00 Oct 27, 2010");
            double oneDay = 24 * 60 * 60;

            // Create graph from theme
            graph = new CPTXYGraph (CGRect.CGRectZero);
            CPTTheme theme = CPTTheme.ThemeNamed (CPTTheme.kCPTDarkGradientTheme);
            graph.ApplyTheme (theme);
            hostView.HostedGraph = graph;

            // Setup scatter plot space
            CPTXYPlotSpace plotSpace = graph.DefaultPlotSpace.CastTo<CPTXYPlotSpace> ();
            double xLow = oneDay * 0.5;
            plotSpace.XRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (xLow), NSDecimal.FromDouble (oneDay * 5.0));
            plotSpace.YRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (1.0), NSDecimal.FromDouble (3.0));

            // Axes
            CPTXYAxisSet axisSet = graph.AxisSet.CastTo<CPTXYAxisSet> ();
            CPTXYAxis x = axisSet.XAxis;
            x.MajorIntervalLength = NSDecimal.FromDouble (oneDay);
            x.OrthogonalCoordinateDecimal = NSDecimal.FromString ("2");
            x.MinorTicksPerInterval = 0;
            NSDateFormatter dateFormatter = new NSDateFormatter ().Autorelease<NSDateFormatter> ();
            dateFormatter.DateStyle = NSDateFormatterStyle.NSDateFormatterShortStyle;
            CPTTimeFormatter timeFormatter = new CPTTimeFormatter (dateFormatter).Autorelease<CPTTimeFormatter> ();
            timeFormatter.ReferenceDate = refDate;
            x.LabelFormatter = timeFormatter;

            CPTXYAxis y = axisSet.YAxis;
            y.MajorIntervalLength = NSDecimal.FromString (@"0.5");
            y.MinorTicksPerInterval = 5;
            y.OrthogonalCoordinateDecimal = NSDecimal.FromDouble (oneDay);

            // Create a plot that uses the data source method
            CPTScatterPlot dataSourceLinePlot = new CPTScatterPlot ().Autorelease<CPTScatterPlot> ();
            dataSourceLinePlot.Identifier = PLOT_IDENTIFIER;

            // Add line style
            CPTMutableLineStyle lineStyle = CPTMutableLineStyle.LineStyle;
            lineStyle.LineWidth = 3.0;
            lineStyle.LineColor = CPTColor.GreenColor;
            dataSourceLinePlot.DataLineStyle = lineStyle;

            // Add plot
            graph.AddPlot (dataSourceLinePlot);
            dataSourceLinePlot.DataSource = this;

            // Add some data
            NSMutableArray newData = new NSMutableArray();
            NSUInteger i;
            Random rand = new Random ();
            for (i = 0; i < 5; i++) {
                double xx = oneDay * (i + 1.0);
                double yy = 3.0 * rand.Next () / (double)Int32.MaxValue + 1.2;

                newData.AddObject (NSDictionary.DictionaryWithObjectsAndKeys (
                                                                              NSDecimalNumber.NumberWithDouble (xx), CPTScatterPlot.FieldX,
                                                                              NSDecimalNumber.NumberWithDouble (yy), CPTScatterPlot.FieldY,
                                                                              null));
            }

            plotData = newData;
        }