private void UpdateGlyphsWithCurrentFontSize()
        {
            //actvw.StartAnimating ();
            LoadFontAndGatherGlyphInfos(this.unitFontSize, (glyphInfos) => {
                InvokeOnMainThread(() => {
                    //actvw.StopAnimating ();
                    if (glyphInfos != null)
                    {
                        int nValid = 0;
                        int nNG    = 0;
                        glyphInfos.ForEach((gi) => {
                            if (gi.GlyphId != 0)
                            {
                                ++nValid;
                            }
                            else
                            {
                                ++nNG;
                            }
                        });

                        Window.LabelStatus.StringValue = String.Format("{0} glyphs, {1} valid, {2} NG", glyphInfos.Count, nValid, nNG);

                        _tableViewSource = new XTableViewSource(glyphInfos);
                        _tableViewSource.SetRowHeight(CalculateRowHeightFromUnitFontSize(this.unitFontSize));
                        NSTableColumn[] columns = Window.TableView.TableColumns();
                        var imgcol      = columns.SingleOrDefault((col) => NSObject.Equals(col.Identifier, _idImageColumn));
                        imgcol.MinWidth = imgcol.MaxWidth = (float)this.unitFontSize;

                        Window.TableView.Source = _tableViewSource;
                        Window.TableView.ReloadData();
                    }
                });
            });
        }
示例#2
0
        public static void TestXml()
        {
            // Parse an example plist file
            NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));

            // check the data in it
            NSDictionary d = (NSDictionary)x;

            Assert.True(d.Count == 5);
            Assert.True(((NSString)d.ObjectForKey("keyA")).ToString().Equals("valueA"));
            Assert.True(((NSString)d.ObjectForKey("key&B")).ToString().Equals("value&B"));
            Assert.True(((NSDate)d.ObjectForKey("date")).Date.ToUniversalTime().Equals(new DateTime(2011, 11, 28, 10, 21, 30, DateTimeKind.Utc)) ||
                        ((NSDate)d.ObjectForKey("date")).Date.ToUniversalTime().Equals(new DateTime(2011, 11, 28, 9, 21, 30, DateTimeKind.Utc)));
            Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes,
                                    new byte[] { 0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, (byte)0x82 }));
            NSArray a = (NSArray)d.ObjectForKey("array");

            Assert.True(a.Count == 4);
            Assert.True(a.ObjectAtIndex(0).Equals(new NSNumber(true)));
            Assert.True(a.ObjectAtIndex(1).Equals(new NSNumber(false)));
            Assert.True(a.ObjectAtIndex(2).Equals(new NSNumber(87)));
            Assert.True(a.ObjectAtIndex(3).Equals(new NSNumber(3.14159)));

            // read/write it, make sure we get the same thing
            PropertyListParser.SaveAsXml(x, new FileInfo("test-files/out-testXml.plist"));
            NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testXml.plist"));

            Assert.True(x.Equals(y));
        }
示例#3
0
        public static void TestIssue38()
        {
            NSDictionary dict    = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue33.pbxproj"));
            NSObject     fileRef = ((NSDictionary)((NSDictionary)dict.Get("objects")).Get("65541A9C16D13B8C00A968D5")).Get("fileRef");

            Assert.True(fileRef.Equals(new NSString("65541A9B16D13B8C00A968D5")));
        }
示例#4
0
        static NSExpression ToExpression(NSObject @object)
        {
            switch (@object)
            {
            case NSArray array:
                return(ToExpression(array));

            case NSString @string:
            case NSNumber number:
            case NSValue value:
                return(NSExpression.FromConstant(@object));

            case NSDictionary dict: {
                var dictionary = new NSMutableDictionary();

                foreach (var key in dict.Keys)
                {
                    dictionary[key] = ToExpression(dict[key]);
                }

                return(NSExpression.FromConstant(dictionary));
            }
            }

            if (@object == null || @object.Equals(NSNull.Null))
            {
                return(NSExpressionAdditions.FromConstant(null));
            }

            return(null);
        }
示例#5
0
        public void Equality()
        {
            using (var o1 = new NSObject())
                using (var o2 = new NSObject()) {
                    Assert.False(o1.Equals((object)null), "Equals(object) null");
                    Assert.False(o1.Equals((object)o2), "Equals(object) 1-2");
                    Assert.False(o2.Equals((object)o1), "Equals(object) 2-1");

                    Assert.False(o1.Equals(3), "Equals(object) 1-3");

                    Assert.False(o1.Equals((NSObject)null), "Equals(NSObject) null");
                    Assert.False(o1.Equals((NSObject)o2), "Equals(NSObject) 1-2");
                    Assert.False(o2.Equals((NSObject)o1), "Equals(NSObject) 2-1");

                    // on a more positive note...
                    Assert.True(o1.Equals((object)o1), "Equals(object) 1-1");
                    Assert.True(o2.Equals((NSObject)o2), "Equals(NSObject) 2-2");
                }
        }
示例#6
0
        public static void TestBinary()
        {
            NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));

            // save and load as binary
            PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testBinary.plist"));
            NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testBinary.plist"));

            Assert.True(x.Equals(y));
        }
示例#7
0
        public static void TestIssue7()
        {
            // also a test for issue 12
            // the issue4 test has a UTF-16-BE string in its binary representation
            NSObject x = PropertyListParser.Parse(new FileInfo("test-files/issue4.plist"));

            PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testIssue7.plist"));
            NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testIssue7.plist"));

            Assert.True(x.Equals(y));
        }
            public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row)
            {
                if (NSObject.Equals(tableColumn.Identifier, MainWindowController._idImageColumn))
                {
                    NSImageView imageView = tableView.MakeView("GlyphView", this) as NSImageView;
                    if (imageView == null)
                    {
                        imageView = new XImageView();
                        SetIdentifierToView(imageView, "GlyphView");
                    }
                    var img = new NSImage(glyphInfos[row].GlyphImage, new SizeF(rowHeight - 2f, rowHeight - 2f));
                    imageView.Image = img;
                    return(imageView);
                }
                else if (NSObject.Equals(tableColumn.Identifier, MainWindowController._idNameColumn))
                {
                    NSTextField textfield = tableView.MakeView("NameView", this) as NSTextField;
                    if (textfield == null)
                    {
                        textfield = new NSTextField();
                        //textfield.BackgroundColor = NSColor.DarkGray;
                        textfield.BackgroundColor = NSColor.FromDeviceWhite(0f, 0.5f);
                        textfield.Bordered        = false;
                        SetIdentifierToView(textfield, "NameView");
                        //textfield.Alignment = NSTextAlignment.Center;
                        textfield.Cell = new XTextFieldCell(textfield);
                    }

                    textfield.StringValue = glyphInfos[row].GlyphName;

                    return(textfield);
                }
                else if (NSObject.Equals(tableColumn.Identifier, MainWindowController._idDetailColumn))
                {
                    NSTextField textfield = tableView.MakeView("DetailView", this) as NSTextField;
                    if (textfield == null)
                    {
                        textfield = new NSTextField();
                        //textfield.BackgroundColor = NSColor.DarkGray;
                        textfield.BackgroundColor = NSColor.FromDeviceWhite(0f, 0.5f);
                        textfield.Bordered        = false;
                        SetIdentifierToView(textfield, "DetailView");

                        textfield.Cell = new XTextFieldCell(textfield);
                    }

                    textfield.StringValue = String.Format("\"{0}\" 0x{1:x}", glyphInfos[row].RawName, glyphInfos[row].GlyphId);

                    return(textfield);
                }
                return(null);
            }
示例#9
0
        public void SubclassEquality()
        {
            using (var o1 = new NSObject())
                using (var o2 = new NSOverrideEqualObject(true))
                    using (var o3 = new NSOverrideEqualObject(false)) {
                        // true, same object
                        Assert.True(o1.Equals(o1), "direct - direct / same");
                        Assert.True(o3.Equals(o3), "indirect - indirect / same");

                        // false, good since there's state in o2 and o3 that does not exists in o1 (direct / native only)
                        Assert.False(o1.Equals(o2), "direct - indirect");
                        Assert.False(o3.Equals(o1), "indirect - direct");

                        // default is false, which is good since the managed state (Throw) differs between o2 and o3
                        Assert.False(o3.Equals(o2), "indirect - indirect");

                        // throws (as implemented above)
                        Assert.Throws <NotFiniteNumberException> (() => { o2.Equals((object)o1); }, "Equals(object) 2-1");

                        // throws (as IEquatable<NSObject>.Equals calls _overriden_ Equals
                        Assert.Throws <NotFiniteNumberException> (() => { o2.Equals((NSObject)o1); }, "Equals(NSObject) 2-1");
                    }
        }
示例#10
0
 public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
 {
     if (keyPath.IsEqual(HiddenProperty) && ofObject.Equals(ContentView))
     {
         if (ContentView.Hidden)
         {
             OnHidden();
         }
         else
         {
             OnShown();
         }
     }
 }
示例#11
0
        public override NSDragOperation DraggingUpdated(NSDraggingInfo sender)
        {
            //The ImageBrowserView uses this method to set the icon during dragging. Regardless
            //of what we return the view will send a moveitems message to the datasource.
            //so it is best to not display the copy icon.

            //Console.WriteLine ("Drag Delegate received 'DraggingUpdated'");
            NSObject obj = sender.DraggingSource;

            if (obj != null && obj.Equals(browserView))
            {
                return(NSDragOperation.Move);
            }
            return(NSDragOperation.Copy);
        }
示例#12
0
 public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
 {
     if (keyPath.ToString() == HiddenProperty.ToString() && ofObject.Equals(ContentView))
     {
         if (ContentView.Hidden)
         {
             if (eventsEnabled.HasFlag(WindowFrameEvent.Hidden))
             {
                 OnHidden();
             }
         }
         else
         {
             if (eventsEnabled.HasFlag(WindowFrameEvent.Shown))
             {
                 OnShown();
             }
         }
     }
 }
示例#13
0
        public override bool PerformDragOperation(NSDraggingInfo sender)
        {
            Console.WriteLine("Drag Delegate received 'PerformDragOperation' sender: {0}", sender);

            //It seems that browserView does not send this message when it is an internal move.
            //It does all the work by sending a moveitems message to the datasource,
            // but I return false here just to be safe.

            NSObject obj = sender.DraggingSource;

            if (obj != null && obj.Equals(browserView))
            {
                Console.WriteLine("\tLet the image browser handle it.");
                return(false);
            }

            NSPasteboard pb   = sender.DraggingPasteboard;
            NSArray      data = null;

            //			if (pb.Types.Contains (NSPasteboard.NSUrlType))
            //				data = pb.GetPropertyListForType (NSPasteboard.NSUrlType) as NSArray;
            if (pb.Types.Contains(NSPasteboard.NSFilenamesType))
            {
                data = pb.GetPropertyListForType(NSPasteboard.NSFilenamesType) as NSArray;
            }
            if (data != null)
            {
                for (int i = 0; i < (int)data.Count; i++)
                {
                    string path = (string)NSString.FromHandle(data.ValueAt((uint)i));
                    Console.WriteLine("From pasteboard Item {0} = {1}", i, path);
                    ((BrowseData)browserView.DataSource).AddImages(
                        NSUrl.FromFilename(path), (int)browserView.GetIndexAtLocationOfDroppedItem());
                    browserView.ReloadData();
                }
            }
            return(true);
        }
示例#14
0
        bool HasUbiquityIdentityChanged()
        {
            if (StorageOption != StorageType.Cloud)
            {
                return(false);
            }

            bool     hasChanged   = false;
            NSObject currentToken = NSFileManager.DefaultManager.UbiquityIdentityToken;
            NSObject storedToken  = FetchStoredUbiquityIdentityToken();

            bool currentTokenNullStoredNonNull = currentToken == null && storedToken != null;
            bool storedTokenNullCurrentNonNull = storedToken == null && currentToken != null;
            bool currentNotEqualStored         = currentToken != null && storedToken != null &&
                                                 !currentToken.Equals(storedToken);

            if (currentTokenNullStoredNonNull || storedTokenNullCurrentNonNull || currentNotEqualStored)
            {
                StoreUbiquityIdentityToken();
                hasChanged = true;
            }

            return(hasChanged);
        }