Exemplo n.º 1
0
        public static void AddRequiredDeviceCapability(IIgorModule ModuleInst, string PlistPath, string NewRequiredDeviceCapability)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary.ContainsKey("UIRequiredDeviceCapabilities"), "Can't find UIRequiredDeviceCapabilities in plist."))
                            {
                                NSObject DeviceCapabilities = RootDictionary.Get("UIRequiredDeviceCapabilities");

                                if (IgorAssert.EnsureTrue(ModuleInst, DeviceCapabilities != null, "Plist does not contain UIRequiredDeviceCapabilities."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(DeviceCapabilities.GetType()), "Plist UIRequiredDeviceCapabilities is not an array."))
                                    {
                                        NSArray CapabilitiesArray = (NSArray)DeviceCapabilities;

                                        if (IgorAssert.EnsureTrue(ModuleInst, CapabilitiesArray != null, "UIRequiredDeviceCapabilities is not an array."))
                                        {
                                            if (CapabilitiesArray.ContainsObject(new NSString(NewRequiredDeviceCapability)))
                                            {
                                                IgorDebug.Log(ModuleInst, "UIRequiredDeviceCapabilities already contains " + NewRequiredDeviceCapability);
                                            }
                                            else
                                            {
                                                NSSet NewCapabilitiesSet = new NSSet(CapabilitiesArray.GetArray());

                                                NewCapabilitiesSet.AddObject(new NSString(NewRequiredDeviceCapability));

                                                NSArray NewCapabilitiesArray = new NSArray(NewCapabilitiesSet.AllObjects());

                                                RootDictionary["UIRequiredDeviceCapabilities"] = NewCapabilitiesArray;

                                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                                IgorDebug.Log(ModuleInst, NewRequiredDeviceCapability + " added to UIRequiredDeviceCapabilities.");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        void TouchesMovedWithEvent(NSSet touches, UIEvent theEvent)
        {
            if (touches.Count == 1)
            {
                this.TouchCount++;
                if (this.TouchCount == 3)
                {
                    if (Math.Abs(this.Center.X - this.OriginalCenter.X) > Math.Abs(this.Center.Y - this.OriginalCenter.Y)) this.MoveLaterally = true;
                    else this.MoveLaterally = false;

                    this.FirstEdgeHit = true;
                }

                UITouch touch = touches.AllObjects().FirstObject();
                CGPoint center = this.Center;
                CGPoint currentLoc = touch.LocationInView(this);
                CGPoint prevLoc = touch.PreviousLocationInView(this);
                if (this.TouchCount < 3)
                {
                    center.X += (currentLoc.X - prevLoc.X);
                    center.Y += (currentLoc.Y - prevLoc.Y);
                }
                else
                {
                    if (this.MoveLaterally)
                    {
                        if (currentLoc.X - prevLoc.X < 0.0f && !this.AllowLeft) return;
                        else if (currentLoc.X - prevLoc.X > 0.0f && !this.AllowRight) return;

                        center.X += (currentLoc.X - prevLoc.X);
                    }
                    else
                    {
                        if (currentLoc.Y - prevLoc.Y < 0.0f && !this.AllowUp) return;
                        else if (currentLoc.Y - prevLoc.Y > 0.0f && !this.AllowDown) return;

                        center.Y += (currentLoc.Y - prevLoc.Y);
                    }

                }

                this.Center = center;
                if (this.MoveLaterally)
                {
                    if ((this.Center.X + this.Frame.Size.Width / 2) > this.Superview.Frame.Size.Width)
                    {
                        this._resetRotation(KSDirection.Right);
                        this.LastDirection = KSDirection.Right;
                        if (this.FirstEdgeHit)
                        {
                            this.FirstEdgeHit = false;
                            this.Shift = new CGPoint(0, 0);
                        }

                        this.Shift.X += (currentLoc.X - prevLoc.X);
                        this._changeViewOpacityForDirection(KSDirection.Right);
                        if (s_hasRightOverlay)
                        {
                            this._showOverlayWithDirectionCurrentLocationPreviousLocation(KSDirection.Right, currentLoc, prevLoc);
                            return;
                        }

                        this.Transform = CGAffineTransform.MakeRotation(Constants.KRotationFactor * this.Shift.X * Math.PI / 180);
                    }
                    else if ((this.Center.X - this.Frame.Size.Width / 2) < 0)
                    {
                        this._resetRotation(KSDirection.Left);
                        this.LastDirection = KSDirection.Left;
                        if (this.FirstEdgeHit)
                        {
                            this.FirstEdgeHit = false;
                            this.Shift = new CGPoint(0, 0);
                        }

                        this.Shift.X += (currentLoc.X - prevLoc.X);
                        this._changeViewOpacityForDirection(KSDirection.Left);
                        if (s_hasLeftOverlay)
                        {
                            this._showOverlayWithDirectionCurrentLocationPreviousLocation(KSDirection.Left, currentLoc, prevLoc);
                            return;
                        }

                        this.Transform = CGAffineTransform.MakeRotation(Constants.KRotationFactor * this.Shift.X * Math.PI / 180);
                    }
                    else
                    {
                        this.Transform = CGAffineTransform.MakeRotation(0);
                        this.Layer.Opacity = 1.0f;
                        this._hideViewOverlays();
                    }

                }
                else
                {
                    if ((this.Center.Y + this.Frame.Size.Height / 2) > this.Superview.Frame.Size.Height)
                    {
                        if (this.FirstEdgeHit)
                        {
                            this.FirstEdgeHit = false;
                            this.Shift = new CGPoint(0, 0);
                        }

                        this.Shift.Y += (currentLoc.Y - prevLoc.Y);
                        this._changeViewOpacityForDirection(KSDirection.Down);
                        this._showOverlayWithDirectionCurrentLocationPreviousLocation(KSDirection.Down, currentLoc, prevLoc);
                    }
                    else if ((this.Center.Y - this.Frame.Size.Height / 2) < 0)
                    {
                        if (this.FirstEdgeHit)
                        {
                            this.FirstEdgeHit = false;
                            this.Shift = new CGPoint(0, 0);
                        }

                        this.Shift.Y += (currentLoc.Y - prevLoc.Y);
                        this._changeViewOpacityForDirection(KSDirection.Up);
                        this._showOverlayWithDirectionCurrentLocationPreviousLocation(KSDirection.Up, currentLoc, prevLoc);
                    }
                    else
                    {
                        this._hideViewOverlays();
                    }

                }

            }

        }