Example #1
0
        public static CFProxy[] GetProxiesForURL(NSUrl url, CFProxySettings proxySettings)
        {
            if (url == null)
            {
                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);
        }
Example #2
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);
        }
Example #3
0
        public static bool CanReadItemWithDataConformingToTypes(this NSPasteboard pasteboard, NSString[] utiTypes)
        {
            NSApplication.EnsureUIThread();
            if (utiTypes == null)
            {
                throw new ArgumentNullException(nameof(utiTypes));
            }
            NSArray nSArray = NSArray.FromNSObjects(utiTypes);
            bool    result  = Messaging.bool_objc_msgSend_IntPtr(pasteboard.Handle, selCanReadItemWithDataConformingToTypes_Handle, nSArray.Handle);

            nSArray.Dispose();
            return(result);
        }
        public void GenerateStockUsedPDFPreview()
        {
            NSArray a = NSBundle.MainBundle.LoadNib("DailyStockUsedPDFTemplate", this, null);

            GeneratedPDFView = (UIView)ObjCRuntime.Runtime.GetNSObject(a.ValueAt(0));

            UILabel tl = (UILabel)GeneratedPDFView.ViewWithTag(1);

            tl.Text = "Employee name: " + MyConstants.EmployeeName;
            tl      = (UILabel)GeneratedPDFView.ViewWithTag(2);
            tl.Text = "Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy");

            UITableViewController usedStock = new UITableViewController();

            usedStock.TableView        = (UITableView)GeneratedPDFView.ViewWithTag(3);
            usedStock.TableView.Source = dvc.CreateSizingSource(false);
            usedStock.TableView.ReloadData();

            // WAS :: usedStock.TableView = (UITableView) ((UIView)dvc.TableView);


            // if (dvc.Root[0].Count > 17)
            {
                float calculatedHeight = (float)(dvc.Root[0].Count * Math.Max(dvc.TableView.RowHeight, 44) + 44);
                GeneratedPDFView.Frame    = new CGRect(GeneratedPDFView.Frame.X, GeneratedPDFView.Frame.Y, GeneratedPDFView.Frame.Width, usedStock.TableView.Frame.Y + calculatedHeight + 114);
                usedStock.TableView.Frame = new CGRect(usedStock.TableView.Frame.X, usedStock.TableView.Frame.Y, usedStock.TableView.Frame.Width, calculatedHeight);

                UIView sig = GeneratedPDFView.ViewWithTag(4);
                sig.Frame = new CGRect(sig.Frame.X, usedStock.TableView.Frame.Y + usedStock.TableView.Frame.Height + 8, sig.Frame.Width, sig.Frame.Height);
                tl        = (UILabel)GeneratedPDFView.ViewWithTag(5);
                tl.Frame  = new CGRect(tl.Frame.X, usedStock.TableView.Frame.Y + usedStock.TableView.Frame.Height + 8, tl.Frame.Width, tl.Frame.Height);


                // sig.Dispose (); sig = null;
            }

            if (a != null)
            {
                a.Dispose(); a = null;
            }
            if (tl != null)
            {
                tl.Dispose(); tl = null;
            }
            if (usedStock != null)
            {
                usedStock.Dispose(); usedStock = null;
            }
        }
Example #5
0
            public NSImage DragImageForRows(NSIndexSet dragRows, NSTableColumn[] tableColumns, NSEvent dragEvent, ref CGPoint dragImageOffset)
            {
                var dragInfo = Handler?.DragInfo;
                var img      = dragInfo?.DragImage;

                if (img != null)
                {
                    dragImageOffset = dragInfo.GetDragImageOffset();
                    return(img);
                }

                NSArray nSArray = NSArray.FromNSObjects(tableColumns);
                NSImage result  = Runtime.GetNSObject <NSImage>(Messaging.IntPtr_objc_msgSendSuper_IntPtr_IntPtr_IntPtr_ref_CGPoint(SuperHandle, selDragImageForRowsWithIndexes_TableColumns_Event_Offset_Handle, dragRows.Handle, nSArray.Handle, dragEvent.Handle, ref dragImageOffset));

                nSArray.Dispose();
                return(result);
            }
Example #6
0
        public static ProcessSerialNumber OpenApplication(ApplicationStartInfo application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            if (string.IsNullOrEmpty(application.Application) || !System.IO.Directory.Exists(application.Application))
            {
                throw new ArgumentException("Application is not valid");
            }

            var appParams = new LSApplicationParameters();

            if (application.NewInstance)
            {
                appParams.flags |= LSLaunchFlags.NewInstance;
            }
            if (application.Async)
            {
                appParams.flags |= LSLaunchFlags.Async;
            }

            NSArray argv = null;

            if (application.Args != null && application.Args.Length > 0)
            {
                var        args = application.Args;
                NSObject[] arr  = new NSObject[args.Length];
                for (int i = 0; i < args.Length; i++)
                {
                    arr[i] = new NSString(args[i]);
                }
                argv           = NSArray.FromNSObjects(arr);
                appParams.argv = argv.Handle;
            }

            NSDictionary dict = null;

            if (application.Environment.Count > 0)
            {
                dict = new NSMutableDictionary();
                foreach (var kvp in application.Environment)
                {
                    dict.SetValueForKey(new NSString(kvp.Value), new NSString(kvp.Key));
                }
                appParams.environment = dict.Handle;
            }

            var cfUrl = global::MonoMac.CoreFoundation.CFUrl.FromFile(application.Application);
            ProcessSerialNumber psn;

            try
            {
                appParams.application = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FSRef)));

                if (!CoreFoundation.CFURLGetFSRef(cfUrl.Handle, appParams.application))
                {
                    throw new Exception("Could not create FSRef from CFUrl");
                }

                var status = LSOpenApplication(ref appParams, out psn);
                if (status != OSStatus.Ok)
                {
                    throw new Exception("Failed to start process: " + ((int)status).ToString());
                }
            }
            finally
            {
                if (appParams.application != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(appParams.application);
                }
                appParams.application = IntPtr.Zero;
                if (dict != null)
                {
                    dict.Dispose(); //also ensures the NSDictionary is kept alive for the params
                }
                if (argv != null)
                {
                    argv.Dispose(); //also ensures the NSArray is kept alive for the params
                }
            }

            return(psn);
        }
        public void GeneratePrePlumbingPDFpreview()
        {
            Customer c = _navWorkflow._tabs._jobRunTable.CurrentCustomer;

            NSArray a = NSBundle.MainBundle.LoadNib("PrePlumbingPDFView", this, null);

            _generatedPdfView = (UIView)ObjCRuntime.Runtime.GetNSObject(a.ValueAt(0));

            UIImageView imgv = (UIImageView)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.PuratapLogo);

            using (var image = UIImage.FromBundle("Images/puratap-logo")) imgv.Image = image;

            UILabel tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.CustomerNumber);

            tl.Text = "Customer Number: " + c.CustomerNumber;
            tl      = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.PuratapEmployeeName);
            tl.Text = MyConstants.EmployeeName;             // "Puratap representative: "
            tl      = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.Date);
            tl.Text = "Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy");
            tl      = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.CustomerName);
            tl.Text = "Customer Name: " + String.Format("{0} {1} {2}", c.Title, c.FirstName, c.LastName);

            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.LeakingBrassFittings);
            switch (pr.LeakingFittings)
            {
            case Choices.YesPuratap: { tl.Text = "Leaking brass fittings (Puratap)"; tl.Enabled = true; break; }

            case Choices.YesNonPuratap: { tl.Text = "Leaking brass fittings (non-Puratap)"; tl.Enabled = true; break; }

            case Choices.No: { tl.Text = "No leaking brass fittings"; tl.Enabled = false; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.LeakingTap);
            switch (pr.LeakingTap)
            {
            case Choices.YesPuratap: { tl.Text = "Leaking tap (Puratap)"; tl.Enabled = true; break; }

            case Choices.YesNonPuratap: { tl.Text = "Leaking tap (non-Puratap)"; tl.Enabled = true; break; }

            case Choices.No: { tl.Text = "No leaking tap"; tl.Enabled = false; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.PotentialLeak);
            switch (pr.PotentialLeak)
            {
            case Choices.YesPuratap: { tl.Text = "Potential leak (discolouration of Puratap ball valve)"; tl.Enabled = true; break; }

            case Choices.YesNonPuratap: { tl.Text = "Potential leak (discolouration of Non-Puratap ball valve)"; tl.Enabled = true; break; }

            case Choices.No: { tl.Text = "No discolouration of ball valve found"; tl.Enabled = false; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.OldTubing);
            switch (pr.OldTubing)
            {
            case Choices.Yes: { tl.Text = "Old \"industry stanard\" thin-walled tubing (needs an upgrade)"; tl.Enabled = true; break; }

            case Choices.No: { tl.Text = "Tubing not discoloured and not showing visual signs of wear"; tl.Enabled = false; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.NonPuratapComponents);
            switch (pr.NonPuratapComponents)
            {
            case Choices.Yes: { tl.Text = "Non-Puratap plumbing components used"; tl.Enabled = true; break; }

            case Choices.No: { tl.Text = "No non-Puratap components "; tl.Enabled = false; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.ExistingDamage);
            switch (pr.ExistingDamage)
            {
            case Choices.Yes: { tl.Text = "Existing property damage (see comments for details)"; tl.Enabled = true; break; }

            case Choices.No: { tl.Text = "No pre-existing property damage"; tl.Enabled = false; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.NotPuratapProblem);
            switch (pr.NotAPuratapProblem)
            {
            case Choices.Yes: { tl.Text = "There is a problem not related to Puratap (see comments for details)"; tl.Enabled = true; break; }

            case Choices.No: { tl.Text = "No other problems (not related to Puratap)"; tl.Enabled = false; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.CustomerAcceptedUpgrade);
            switch (pr.UpgradeOffered)
            {
            case Choices.Option1: {
                if (pr.CustomerAcceptedUpgrade == Choices.Yes)
                {
                    tl.Text = "Customer has accepted an offer of Option 1 upgrade";
                }
                if (pr.CustomerAcceptedUpgrade == Choices.No)
                {
                    tl.Text = "Customer has declined an offer of Option 1 upgrade";
                }
                break;
            }

            case Choices.Option2: {
                if (pr.CustomerAcceptedUpgrade == Choices.Yes)
                {
                    tl.Text = "Customer has accepted an offer of Option 2 upgrade";
                }
                if (pr.CustomerAcceptedUpgrade == Choices.No)
                {
                    tl.Text = "Customer has declined an offer of Option 2 upgrade";
                }
                break;
            }

            case Choices.No: {
                tl.Hidden = true;
                tl        = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.UpgradeOfferText);
                tl.Hidden = true;
                break;
            }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.CustomerSignatureLabel);
            switch (pr.UnwillingToSign)
            {
            case Choices.No: { tl.Text = "Customer signature"; break; }

            case Choices.Yes: { tl.Text = "Customer unable or unwilling to sign off. Signed by service representative"; break; }
            }
            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.OfficeFollowUpRequired);
            switch (pr.OfficeFollowUpRequired)
            {
            case Choices.Yes: { tl.Hidden = false; break; }

            case Choices.No: { tl.Hidden = true; break; }
            }

            UITextView comments = (UITextView)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.Comments);

            comments.Text = this.commentsTextView.Text;

            tl = (UILabel)_generatedPdfView.ViewWithTag(MyConstants.PrePlumbingPDFTemplateTags.TubingUpgradeNotice);
            if (pr.UpgradeOffered != Choices.No)
            {
                if (pr.CustomerAcceptedUpgrade != Choices.No)
                {
                    // upgrade was offered and customer accepted
                    Job main = _navWorkflow._tabs._jobRunTable.CurrentJob;
                    if (main.HasParent())
                    {
                        main = _navWorkflow._tabs._jobRunTable.FindParentJob(_navWorkflow._tabs._jobRunTable.CurrentJob);
                    }
                    bool tuInJobCluster = false;
                    if ((main.Type.Code == "TUBINGUPGR" || main.Type.Code == "TUBING") && (main.Warranty == false))
                    {
                        tuInJobCluster = true;
                    }
                    else
                    {
                        foreach (Job child in main.ChildJobs)
                        {
                            if ((child.Type.Code == "TUBINGUPGR" || child.Type.Code == "TUBING") && (child.Warranty == false))
                            {
                                tuInJobCluster = true; break;
                            }
                        }
                    }

                    if (tuInJobCluster)
                    {
                        tl.Text = "Tubing upgrade was offered, accepted and done on the day";
                    }
                    else
                    {
                        tl.Text = "Tubing upgrade was offered, accepted, but NOT DONE on the day.";                             // todo :: create a followup here?
                    }
                }
                else
                {
                    tl.Hidden = true;
                }
            }
            else
            {
                tl.Hidden = true;
            }

            tl.Dispose(); tl             = null;
            comments.Dispose(); comments = null;
            a.Dispose(); a       = null;
            imgv.Dispose(); imgv = null;
        }