示例#1
0
partial         void startStopPing(Foundation.NSObject sender)
        {
            if (task != null) {
                task.Interrupt();
            }
            else {
                task = new NSTask();
                task.LaunchPath = "/sbin/ping";
                string[] args = {"-c10", hostField.StringValue};

                task.Arguments = args;

                // Create a new pipe
                pipe = new NSPipe();
                task.StandardOutput = pipe;

                NSFileHandle fh = pipe.ReadHandle;

                NSNotificationCenter nc = NSNotificationCenter.DefaultCenter;
                nc.RemoveObserver(this);
                nc.AddObserver(this, new Selector("dataReady:"), NSFileHandle.ReadCompletionNotification, fh);
                nc.AddObserver(this, new Selector("taskTerminated:"), NSTask.NSTaskDidTerminateNotification, task);
                task.Launch();
                outputView.Value = "";

                // Suspect = Obj-C example is [fh readInBackgroundAndNotify] - no arguments
                fh.ReadInBackground();
            }
        }
示例#2
0
partial         void moveFile(Foundation.NSObject sender)
        {
            if (textFieldFrom.StringValue == "" || textFieldTo.StringValue == "") {
                textFieldResults.StringValue = "Must set 'from' and 'to' paths";
                return;
            }

            // Prepare a task object
            NSTask task = new NSTask();
            task.LaunchPath = "/bin/mv";
            string[] args = {textFieldFrom.StringValue, textFieldTo.StringValue};
            task.Arguments = args;

            // Create a pipe to read from
            NSPipe outPipe = new NSPipe();
            task.StandardOutput = outPipe;

            // Start the process
            task.Launch();

            // Read the output
            NSData data = outPipe.ReadHandle.ReadDataToEndOfFile();

            // Make sure the task terminates normally
            task.WaitUntilExit();
            int status = task.TerminationStatus;

            // Check status
            if (status != 0) {
                textFieldResults.StringValue = "Move Failed: " + status;
                return;
            }

            textFieldResults.StringValue = String.Format("{0} moved to {1}", textFieldFrom.StringValue, textFieldTo.StringValue);
        }
		public override void RowSelected (UITableView tableView, Foundation.NSIndexPath indexPath)
		{
			var session = sessions[indexPath.Row];
			ConsoleD.WriteLine("SessionsTableSource.RowSelected");			
			view.SelectSession(session);
			if (AppDelegate.IsPhone) tableView.DeselectRow (indexPath, true);
		}
		partial void PreviousCat (Foundation.NSObject sender) {
			// Display previous cat
			if (--PageNumber < 0) {
				PageNumber = 0;
			}
			ShowCat();
		}
示例#5
0
		public override UITableViewCell GetCell (UITableView tableView, Foundation.NSIndexPath indexPath)
		{
			var changeLoginGroup = GroupedData [indexPath.Section];
			var changeLoginEntry = changeLoginGroup.ElementAt (indexPath.Row);

			var cell = (TSDepartmentCell)tableView.DequeueReusableCell (CellId);

			if (cell == null) {
				cell = new TSDepartmentCell (CellId, fontSize);
			}

			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				cell.LayoutMargins = UIEdgeInsets.Zero;
				cell.PreservesSuperviewLayoutMargins = false;
			}

			cell.CellText.Text = changeLoginEntry.EntryData.Title;
			cell.DetailText.Text = changeLoginEntry.EntryData.Detail;
			if (changeLoginEntry.EntryData.Count != null) {
				cell.Count.Alpha = 1;
				cell.Count.Text = changeLoginEntry.EntryData.Count;
			}
			if (changeLoginEntry.EntryData.IsChecked)
				cell.imgCheckmark.Alpha = 1;
				
			cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;

			return cell;
		}
        public override UICollectionViewCell GetCell(UICollectionView collectionView, Foundation.NSIndexPath indexPath)
        {
            var cell = (ListingImageCell)collectionView.DequeueReusableCell(CellID, indexPath);
            cell.Image = urls[indexPath.Row];

            return cell;
        }
示例#7
0
        public void ShowAboutPanel(Foundation.NSObject sender)
        {
            // The strict chap 12 challenge solution. non-modal, no window controller for the about panel
            // so multiple about panels can be displayed
            //			NSBundle.LoadNib("About", this);
            //			aboutPanel.MakeKeyAndOrderFront(null);

            // Make about panel modal and position it in the center of the active window
            NSBundle.LoadNib("About", this);
            // Change BG color and posiiton
            aboutPanel.BackgroundColor = NSColor.White;
            if (NSApplication.SharedApplication.MainWindow != null) {
                var mainWindowFrame = NSApplication.SharedApplication.MainWindow.Frame;
                nfloat x = mainWindowFrame.X + mainWindowFrame.Width/2 - aboutPanel.Frame.Width/2;
                nfloat y = mainWindowFrame.Y + mainWindowFrame.Height/2 - aboutPanel.Frame.Height/2;
                aboutPanel.SetFrame(new CGRect(x, y, aboutPanel.Frame.Width, aboutPanel.Frame.Height), true);
            }
            else {
                NSScreen screen = NSScreen.MainScreen;
                aboutPanel.SetFrame(new CGRect(screen.Frame.Width/2-aboutPanel.Frame.Width/2, screen.Frame.Height - aboutPanel.Frame.Height - 100, aboutPanel.Frame.Width, aboutPanel.Frame.Height), true);
            }
            // Stop modal when about panel closed.
            aboutPanel.WillClose += (object s, EventArgs e) =>  {
                Console.WriteLine("Window will close");
                NSApplication.SharedApplication.StopModal();
            };
            // Show modal about panel
            NSApplication.SharedApplication.RunModalForWindow(aboutPanel);
        }
		partial void OnConnect (Foundation.NSObject sender)
		{
			ActionHelper.Execute(delegate() {
					
				if (ConnectPopupButton.SelectedItem.Title != "New Server")
				{	
					var server = ConnectPopupButton.SelectedItem.Title;
					var tokens = SnapInContext.Instance.AuthTokenManager.GetAllAuthTokens ();
					var serverDto = tokens.Where(x=>x.ServerDto != null && x.ServerDto.ServerName == server).Select(x=>x.ServerDto).FirstOrDefault();
					if (!WebUtil.PingHost (serverDto.ServerName)) {
						UIErrorHelper.ShowAlert ("Server name or ip address no longer exists or not reachable", "Alert");
						return;
					}
					else
					{
						var mainWindowController = new MainWindowController (serverDto);
						mainWindowController.Window.MakeKeyAndOrderFront (null);
					}
				}
				else
				{
					//var controller = new AddNewServerController ();
					var mainWindowController = new MainWindowController ();
					mainWindowController.Window.MakeKeyAndOrderFront (null);
				}
				this.Window.IsVisible = false;
				//this.Close ();
			});
		}
        //
        public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesBegan (touches, evt);
            UITouch touch1 = evt.AllTouches.AnyObject as UITouch;
            CGPoint point = touch1.LocationInView (View);

            if (point.X > lbl1.Frame.X && point.X < lbl1.Frame.X + lbl1.Frame.Size.Width && point.Y > lbl1.Frame.Y && point.Y < lbl1.Frame.Y + lbl1.Frame.Size.Height) {

                myLab = lbl1;
            }
            if (point.X > lbl2.Frame.X && point.X < lbl2.Frame.X + lbl2.Frame.Size.Width && point.Y > lbl2.Frame.Y && point.Y < lbl2.Frame.Y + lbl2.Frame.Size.Height) {

                myLab = lbl2;
            }
            if (point.X > lbl3.Frame.X && point.X < lbl3.Frame.X + lbl3.Frame.Size.Width && point.Y > lbl3.Frame.Y && point.Y < lbl3.Frame.Y + lbl3.Frame.Size.Height) {

                myLab = lbl3;
            }
            if (point.X > lbl4.Frame.X && point.X < lbl4.Frame.X + lbl4.Frame.Size.Width && point.Y > lbl4.Frame.Y && point.Y < lbl4.Frame.Y + lbl4.Frame.Size.Height) {

                myLab = lbl4;
            }
            if (point.X > lbl5.Frame.X && point.X < lbl5.Frame.X + lbl5.Frame.Size.Width && point.Y > lbl5.Frame.Y && point.Y < lbl5.Frame.Y + lbl5.Frame.Size.Height) {

                myLab = lbl5;
            }
        }
示例#10
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Foundation game = new Foundation())
     {
         game.Run();
     }
 }
		public override void RowSelected (UITableView tableView, Foundation.NSIndexPath indexPath)
		{
			tableView.DeselectRow (indexPath, true);
			var changeLoginGroup = GroupedData [indexPath.Section];
			var changeLoginEntry = changeLoginGroup.ElementAt (indexPath.Row);
			if (changeLoginEntry.OnClickAction != null) {
                if (!CrossConnectivity.Current.IsConnected)
                {
                    DialogUtil.ShowAlert("Network Unavailable", "This application requires internet access to function. Please check your connection and try again.", "OK");
                    return;
                }
                else
                {
                    if (changeLoginEntry.OnClickAction.Equals("PushChangePin"))
                    {
                        controller.NavigationController.PushViewController(new RSChangePinViewController(), true);
                    }
                    else if (changeLoginEntry.OnClickAction.Equals("PushChangePassword"))
                    {
                        controller.NavigationController.PushViewController(new RSChangePasswordViewController(), true);
                    }
                    else if (changeLoginEntry.OnClickAction.Equals("PushChangeUserID"))
                    {
                  
                        controller.NavigationController.PushViewController(new RSChangeUserIdViewController(), true);
                    }
                }
			}
		}
        public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            var tableCell = tableView.DequeueReusableCell (cellId);

            if (tableCell == null) {
                tableCell = new UITableViewCell (
                    UITableViewCellStyle.Subtitle,
                    cellId
                );
                tableCell.SelectionStyle = UITableViewCellSelectionStyle.Blue;
                if (tableCell.TextLabel != null) {
                    tableCell.TextLabel.TextColor = UIColor.White;
                }
                tableCell.BackgroundColor = UIColor.FromRGB (9, 34, 65);

                var backgroundView = new UIView ();
                backgroundView.BackgroundColor = UIColor.FromRGB (88, 181, 222);
                tableCell.SelectedBackgroundView = backgroundView;

                tableCell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                tableCell.TintColor = UIColor.White;
            }

            var entry = Entries [indexPath.Row];
            tableCell.TextLabel.Text = entry;

            return tableCell;
        }
示例#13
0
		/// <summary>
		/// Called by the TableView to get the actual UITableViewCell to render for the particular section and row
		/// </summary>
		public override UITableViewCell GetCell (UITableView tableView, Foundation.NSIndexPath indexPath)
		{
			// declare vars
			UITableViewCell cell = tableView.DequeueReusableCell (cellIdentifier);
			TableItem item = tableItems[indexPath.Section].Items[indexPath.Row];
			
			// if there are no cells to reuse, create a new one
			if (cell == null)
				cell = new UITableViewCell (item.CellStyle, cellIdentifier);
			
			// set the item text
			cell.TextLabel.Text = tableItems[indexPath.Section].Items[indexPath.Row].Heading;
			
			// if it's a cell style that supports a subheading, set it
			if(item.CellStyle == UITableViewCellStyle.Subtitle 
			   || item.CellStyle == UITableViewCellStyle.Value1
			   || item.CellStyle == UITableViewCellStyle.Value2)
			{ cell.DetailTextLabel.Text = item.SubHeading; }
			
			// if the item has a valid image, and it's not the contact style (doesn't support images)
			if(!string.IsNullOrEmpty(item.ImageName) && item.CellStyle != UITableViewCellStyle.Value2)
			{
				if(File.Exists(item.ImageName))
					cell.ImageView.Image = UIImage.FromBundle(item.ImageName);
			}
			
			// set the accessory
			cell.Accessory = item.CellAccessory;
			
			return cell;
		}
        public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            var cell = (FeedResultsCell)tableView.DequeueReusableCell(FeedResultsCell.Key);

            if (cell == null)
            {
                cell = new FeedResultsCell();
            }

            cell.BackgroundColor = ColorScheme.Clouds;
            Posting post = savedListings[indexPath.Row];

            cell.PostingTitle.AttributedText = new NSAttributedString(post.PostTitle, Constants.HeaderAttributes);
            cell.PostingDescription.AttributedText = new NSAttributedString(post.Description, Constants.FeedDescriptionAttributes);
            if (post.ImageLink != "-1")
            {
                cell.PostingImage.SetImage(
                    url: new NSUrl(post.ImageLink),
                    placeholder: UIImage.FromBundle("placeholder.png")
                );
            }
            else
            {
                cell.PostingImage.Image = UIImage.FromBundle("placeholder.png");
            }

            return cell;
        }
示例#15
0
		partial void PlayerCountChanged (Foundation.NSObject sender) {

			// Take Action based on the segment
			switch(PlayerCount.SelectedSegment) {
			case 0:
				Player1.Hidden = false;
				Player2.Hidden = true;
				Player3.Hidden = true;
				Player4.Hidden = true;
				break;
			case 1:
				Player1.Hidden = false;
				Player2.Hidden = false;
				Player3.Hidden = true;
				Player4.Hidden = true;
				break;
			case 2:
				Player1.Hidden = false;
				Player2.Hidden = false;
				Player3.Hidden = false;
				Player4.Hidden = true;
				break;
			case 3:
				Player1.Hidden = false;
				Player2.Hidden = false;
				Player3.Hidden = false;
				Player4.Hidden = false;
				break;
			}
		}
		public override UITableViewCell GetCell (UITableView tableView, Foundation.NSIndexPath indexPath)
		{
			var item = Data[indexPath.Row];

			var cell = (ByInvestmentTableViewCell)tableView.DequeueReusableCell (investmentId);

			if (cell == null)
				cell = new ByInvestmentTableViewCell (investmentId, sourceNames);	

			//cell.SeparatorInset = new UIEdgeInsets (0, 0, 0, 10);

			cell.FundNameLabel.Text = item.FundName;
			cell.SelectionStyle = UITableViewCellSelectionStyle.None;

			var x = 0;

			foreach (var name in sourceNames) {
				cell.SourceAmounts [x].Item1.Text = name;

				var amount = 0.00;

				if (item.SourceAmounts.ContainsKey (name)) {
					amount = item.SourceAmounts [name];
				}
				cell.SourceAmounts [x].Item2.Text = String.Format ("{0:C}", amount);
				x++;
			}
			return cell;
		}
示例#17
0
		public override void RowSelected (UITableView tableView, Foundation.NSIndexPath indexPath)
		{
			tableView.DeselectRow (indexPath, true);
			var changeLoginGroup = GroupedData [indexPath.Section];
			var changeLoginEntry = changeLoginGroup.ElementAt (indexPath.Row);
			if (changeLoginEntry.OnClickAction != null) {
				if (TSPhoneSpec.UserInterfaceIsPhone) {
					if (changeLoginEntry.OnClickAction.Equals ("PushSales")) {
						controller.NavigationController.PushViewController (new TSAddDepartmentVC (controller), true);
					} else if (changeLoginEntry.OnClickAction.Equals ("PushService")) {
						//controller.NavigationController.PushViewController (new TSSetupCodeVC (), true);
					} else if (changeLoginEntry.OnClickAction.Equals ("PushParts")) {
						//controller.NavigationController.PushViewController (new TSDepartmentsVC (), true);
					}
				} else {

					if (changeLoginEntry.OnClickAction.Equals ("PushSales")) {
						var obj = new TSAddDepartmentVC(controller,settingView);
						settingView.AddPartialView(obj.getAddDepartmentView());
					} else if (changeLoginEntry.OnClickAction.Equals ("PushService")) {
						//controller.NavigationController.PushViewController (new TSSetupCodeVC (), true);
					} else if (changeLoginEntry.OnClickAction.Equals ("PushParts")) {
						//controller.NavigationController.PushViewController (new TSDepartmentsVC (), true);
					}
				}
			}
		}
		partial void Page3Pressed (Foundation.NSObject sender) {

			// Update GUI
			DetailController.Title = "Sweet or Sour?";
			DetailController.FirstChoice = "Candy";
			DetailController.SecondChoice = "Lemons";
		}
		partial void Page2Pressed (Foundation.NSObject sender) {

			// Update GUI
			DetailController.Title = "Wet or Dry?";
			DetailController.FirstChoice = "Desert";
			DetailController.SecondChoice = "Ocean";
		}
		//IBActions
		partial void EditProfileClicked (Foundation.NSObject sender){
			try{
				Master.PerformSegue("Profile2EditProfile", sender);
			} catch (Exception e){
				Console.WriteLine(e.Message);
			}
		}
示例#21
0
		/// <summary>
		/// Gets the child.
		/// </summary>
		/// <returns>The child.</returns>
		/// <param name="outlineView">Outline view.</param>
		/// <param name="childIndex">Child index.</param>
		/// <param name="item">Item.</param>
		public override NSObject GetChild (NSOutlineView outlineView, nint childIndex, Foundation.NSObject item)
		{
			if (item == null) {
				return Items [(int)childIndex];
			} else {
				return ((SourceListItem)item) [(int)childIndex]; 
			}
		}
示例#22
0
		/// <summary>
		/// Gets the children count.
		/// </summary>
		/// <returns>The children count.</returns>
		/// <param name="outlineView">Outline view.</param>
		/// <param name="item">Item.</param>
		public override nint GetChildrenCount (NSOutlineView outlineView, Foundation.NSObject item)
		{
			if (item == null) {
				return Items.Count;
			} else {
				return ((SourceListItem)item).Count;
			}
		}
 partial void OnOKButton (Foundation.NSObject sender)
 {
     UIErrorHelper.CheckedExec (delegate() {
         ValidateControls ();
         this.Close ();
         NSApplication.SharedApplication.StopModalWithCode (1);
     });
 }
		partial void ShowStatusPage(Foundation.NSObject sender)
		{
			StatusViewController = (StatusViewController)Storyboard.InstantiateViewController("StatusViewController");
			StatusViewController.View.BackgroundColor = UIColor.FromWhiteAlpha(0, (nfloat).8);
			StatusViewController.ModalPresentationStyle = UIModalPresentationStyle.Custom;
			StatusViewController.TransitioningDelegate = new Home2StatusTransitionDelegate();
			PresentViewController(StatusViewController, true, null);
		}
		partial void Page1Pressed (Foundation.NSObject sender) {

			// Update GUI
			DetailController.Title = "Hot or Cold?";
			DetailController.FirstChoice = "Fire";
			DetailController.SecondChoice = "Ice";

		}
		/// <summary>
		/// Called before an <c>NSWindow</c> is closed. Applies any preference changes to all open
		/// windows in the app.
		/// </summary>
		/// <returns><c>true</c>, if the window can be closed, else <c>false</c> if it cannot.</returns>
		/// <param name="sender">The <c>NSWindowController</c> calling this method.</param>
		public override bool WindowShouldClose (Foundation.NSObject sender)
		{
			
			// Apply any changes to open windows
			App.UpdateWindowPreferences();

			return true;
		}
		partial void CloseStatusPage (Foundation.NSObject sender)
		{
			UIView.Animate (.25, delegate {
				View.Frame = new CoreGraphics.CGRect (-View.Frame.Size.Width, 0, View.Frame.Size.Width, View.Frame.Size.Height);
			}, delegate {
				DismissViewController(false, null);
			});
		}
示例#28
0
		public override UITableViewCell GetCell (UITableView tableView, Foundation.NSIndexPath indexPath)
		{
			UITableViewCell cell = tableView.DequeueReusableCell ((NSString)cellId);
			cell = cell ?? new CustomCell (UITableViewCellStyle.Default, (NSString)cellId);

			cell.TextLabel.Text = indexPath.Row.ToString ();
			return cell;
		}
示例#29
0
		public static DateTime NSDateToDateTime(Foundation.NSDate date)
		{
			var nsDateNow = (DateTime)NSDate.Now;
			var diff = DateTime.Now.Subtract(nsDateNow);
			var newDate = ((DateTime)date).Add(diff);
		   	return newDate;
			// return (new DateTime(2001,1,1,0,0,0)).AddSeconds(date.SecondsSinceReferenceDate);
		}
        public override void RowSelected(UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            AvailableLocations allLocations = new AvailableLocations();
            var categoryVC = new CategoryPickerViewController();
            categoryVC.SelectedCity = allLocations.PotentialLocations.Find(x => x.SiteName == recentCities[indexPath.Row].City);

            this.owner.ShowViewController(categoryVC, this);
        }