Inheritance: StringElement
		private Section BuildListing(string basePath)
		{
			Section sect = new Section();
			
			foreach(string dir in Directory.GetDirectories(basePath))
			{
				string strDir = dir;
				string strDirDisplay = strDir.Replace(basePath,"");
				if(strDirDisplay[0] == '/')
					strDirDisplay = strDirDisplay.Remove(0,1);
				
				ImageStringElement element = new ImageStringElement (strDirDisplay, imgFolder);
				element.Tapped += delegate { ShowDirectoryTree(strDir, true); };
			
				sect.Add(element);
			}
			
			foreach(string fil in Directory.GetFiles(basePath))
			{
				string strFil = fil;
				string strFilDisplay = strFil.Replace(basePath,"");
				if(strFilDisplay[0] == '/')
					strFilDisplay = strFilDisplay.Remove(0,1);
				
				ImageStringElement element = new ImageStringElement (strFilDisplay, imgFile);
				element.Tapped += delegate { Utilities.UnsuccessfulMessage("File: " + strFil + " tapped"); };
			
				sect.Add(element);
				
			}
			
			return sect;
			
		}
Example #2
0
        public void EchoDicomServer()
        {
            RootElement root = null;
            Section resultSection = null;

            var hostEntry = new EntryElement("Host", "Host name of the DICOM server", "server");
            var portEntry = new EntryElement("Port", "Port number", "104");
            var calledAetEntry = new EntryElement("Called AET", "Called application AET", "ANYSCP");
            var callingAetEntry = new EntryElement("Calling AET", "Calling application AET", "ECHOSCU");

            var echoButton = new StyledStringElement("Click to test",
            delegate {
                if (resultSection != null) root.Remove(resultSection);
                string message;
                var echoFlag = DoEcho(hostEntry.Value, Int32.Parse(portEntry.Value), calledAetEntry.Value, callingAetEntry.Value, out message);
                var echoImage = new ImageStringElement(String.Empty, echoFlag ? new UIImage("yes-icon.png") : new UIImage("no-icon.png"));
                var echoMessage = new StringElement(message);
                resultSection = new Section(String.Empty, "C-ECHO result") { echoImage, echoMessage };
                root.Add(resultSection);
            })
            { Alignment = UITextAlignment.Center, BackgroundColor = UIColor.Blue, TextColor = UIColor.White };

            root = new RootElement("Echo DICOM server") {
                new Section { hostEntry, portEntry, calledAetEntry, callingAetEntry},
                new Section { echoButton },

            };

            var dvc = new DialogViewController (root, true) { Autorotate = true };
            navigation.PushViewController (dvc, true);
        }
        public override void ViewDidLoad()
        {
            Projects = new ProjectsController(NavigationController);
            Settings = new SettingsController(NavigationController);
            MyStories = new MyStoriesController(NavigationController);

            var projectsElement = new ImageStringElement ("Projects", Projects.PushViewController, Projects.Icon);
            projectsElement.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            var settingsElement = new ImageStringElement ("Settings", Settings.PushViewController, Settings.Icon);
            settingsElement.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            var myStoriesElement = new ImageStringElement ("My stories", MyStories.PushViewController, MyStories.Icon);
            myStoriesElement.Accessory = UITableViewCellAccessory.DisclosureIndicator;

            var menu = new RootElement ("Main menu")
            {
                new Section ()
                {
                    projectsElement,
                    myStoriesElement,
                    settingsElement
                }
            };

            var dv = new DialogViewController (menu) {
                Autorotate = true
            };

            NavigationController.PushViewController (dv, false);
        }
Example #4
0
        public void FacebookLoggedIn(bool didLogIn, string accessToken, string userId, Exception error)
        {
            if (didLogIn) {
                var statusElement = dvcController.Root [0].Elements [0] as StyledStringElement;
                statusElement.Caption = "Logged In";
                statusElement.BackgroundColor = UIColor.Green;

                _fb = new FacebookClient (accessToken);

                _fb.GetTaskAsync ("me").ContinueWith( t => {
                    if (!t.IsFaulted) {

                        if (t.Exception != null) {
                            new UIAlertView ("Couldn't Load Profile", "Reason: " + t.Exception.Message, null, "Ok", null).Show ();
                            return;
                        }
                        var result = (IDictionary<string, object>)t.Result;

                        // available picture types: square (50x50), small (50xvariable height), large (about 200x variable height) (all size in pixels)
                        // for more info visit http://developers.facebook.com/docs/reference/api
                        string profilePictureUrl = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", userId, "square", accessToken);
                        UIImage profileImage = UIImage.LoadFromData (NSData.FromUrl (new NSUrl (profilePictureUrl)));

                        string profileName = (string)result["name"];

                        var profile = new ImageStringElement (profileName, profileImage);

                        BeginInvokeOnMainThread ( ()=> {
                            dvcController.Root[0].Add (profile);
                        });

                        isLoggedIn = true;
                    }
                });

            } else {
                new UIAlertView ("Failed to Log In", "Reason: " + error.Message, null, "Ok", null).Show();
            }
        }
        public AddViewController(UIViewController theView, BaseItem ParentTask,long assignedID,int groupID, DateTime duedate)
            : base(null,true)
        {
            this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, delegate{
                this.DeactivateController(true);
            });

            taskElement = new ImageStringElement("Item",Images.boxImg,delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.Item,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? groupID: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate
                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);
            });

            calendarElement = new ImageStringElement("Calendar Event",Images.AppleCalendar,delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                addController = new EKEventEditViewController();
                // set the addController's event store to the current event store.
                addController.EventStore = Util.MyEventStore;
                addController.Event = EKEvent.FromStore(Util.MyEventStore);
                if(duedate.Year < 2000)
                    duedate = DateTime.Today;
                addController.Event.StartDate = duedate.AddHours(DateTime.Now.Hour);
                addController.Event.EndDate = duedate.AddHours(DateTime.Now.Hour + 1);

                addController.Completed += delegate(object theSender, EKEventEditEventArgs eva) {
                    switch (eva.Action)
                    {
                        case EKEventEditViewAction.Canceled :
                            theView.NavigationController.DismissModalViewControllerAnimated(true);
                            break;
                        case EKEventEditViewAction.Deleted :
                            theView.NavigationController.DismissModalViewControllerAnimated(true);
                            break;
                        case EKEventEditViewAction.Saved:
                            theView.NavigationController.DismissModalViewControllerAnimated(true);
                            break;
                    }
                };

                theView.NavigationController.PresentModalViewController(addController,true);
            });

            checkListElement = new ImageStringElement("List",Images.checkListImage, delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new CheckList(assignedID){
                Kind = TaskKind.List,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate
                };

                var taskVC = new DetailViewController(task,true);
                taskVC.TaskListSaved += savedTask => {
                        theView.NavigationController.PushViewController(new TaskViewController(savedTask.Description,true,savedTask),true);
                };

                theView.NavigationController.PushViewController(taskVC,true);
            });

            phoneCallElement = new ImageStringElement("Phone Call",Images.phoneImg, delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.PhoneCall,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate

                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);

            });

            emailElement = new ImageStringElement("Send an Email",Images.emailImg,delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.Email,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate

                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);

            });

            websiteElement = new ImageStringElement("Visit a Website",Images.globeImg,delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.VisitAWebsite,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate

                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);

            });

            Root = new RootElement("Add new item")
            {
                new Section()
                {
                    taskElement,
                    calendarElement,
                    checkListElement,
                },
                new Section()
                {
                    phoneCallElement,
                    emailElement,
                    websiteElement,
                }
            };

            ///
        }
        async private void  onlineElement_ValueChanged( object sender , EventArgs e)
        {

            if (onlineElement.Value == false)
            {
                MessageBox.ShowMessage(this.View, LocalString.GetString("UserOffline"));
                Application._user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;
            }
            else
            {

                if (Application._networkstate == DataAccessLayer.NetworkState.Disconnected)
                {
                    onlineElement.Value = false;
                    return;
                }

                // First save the current setting -> We need them if the connection to the new server fails -> then we have to reset to these settings
                CurrentURL = DataAccessLayer.Utilities.ServerIP;
                CurrentNetworkState = Application._networkstate;

                // Just run the Login ViewController if the user has never logged online before
                if (string.IsNullOrEmpty(Application._user.IdSession))
                {
                    Application._user.NetworkStatus = Application._networkstate;
                    DataAccessLayer.Utilities.ServerIP = urlElement.Value.ToString();

                    // Create a VCSelectAnsprechpartnern dialog
                    loginController = Storyboard.InstantiateViewController<LoginController>();
                    loginController.VCSettings = this;
                    loginController.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

                    PresentViewController(loginController, true, null);

                    return;
                    // After it has finished the LoginController calls UpdateLoggedValues

                }
                else
                {
                    if (await TestConnection() == true)
                    {
                        // connection available and the user is online
                        Application._user.NetworkStatus = Application._networkstate;
                        MessageBox.ShowMessage(this.View, LocalString.GetString("UserOnline"));

                    }
                    else
                    {
                        // No connection
                        onlineElement.Value = false;
                        Application._user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;

                        MessageBox.ShowErrorMessage(this.View, LocalString.GetString("ConnectionFailedTitle"));

                    }
                }

                if (Application._user.NetworkStatus != DataAccessLayer.NetworkState.Disconnected)
                    offlineTasks = BusinessLayer.Task.HasNewOfflineTasks();

                // Ask to upload any unsync data if the user is online 
                if (offlineTasks != 0 && Application._user.NetworkStatus != DataAccessLayer.NetworkState.Disconnected)
                {
                    OfflineDataSection.RemoveRange(1,3);
                    string UploadLabel = "";
                    if (offlineTasks != 0)
                        UploadLabel = "  (" + LocalString.GetString("UnsynchronizedData_") + " " + offlineTasks.ToString() + ")";
                    uploadDataElement = new ImageStringElement(LocalString.GetString("UploadData") + UploadLabel,UIImage.FromFile("Images/ic_action_upload.png"));
                    uploadDataElement.Tapped += delegate()
                        {
                            UploadData();
                        };

                    OfflineDataSection.Add(uploadDataElement);
                    OfflineDataSection.Add(clearofflineDataElement);

                    UploadData();
                }
            }

        }
        private void BuildViewController()
        {
            if (OfflineDataSection != null)
                OfflineDataSection.Clear();

            Reachability.ReachabilityChanged += (object sender, EventArgs e) =>  { UpdateSettings (); };

            onlineElement = new BooleanElement(LocalString.GetString("Online"), Application._user.NetworkStatus != DataAccessLayer.NetworkState.Disconnected);
            onlineElement.ValueChanged +=  onlineElement_ValueChanged;

            urlElement = new StringElement( "Server URL",DataAccessLayer.Utilities.ServerIP);

            // Upload Element
            offlineTasks = BusinessLayer.Task.HasNewOfflineTasks();
            string UploadLabel = "";
            if (offlineTasks != 0)
                UploadLabel = "  (" + LocalString.GetString("UnsynchronizedData_") + " " + offlineTasks.ToString() + ")";
            uploadDataElement = new ImageStringElement(LocalString.GetString("UploadData") + UploadLabel,UIImage.FromFile("Images/ic_action_upload.png"));
            uploadDataElement.Tapped += delegate()
                {
                    UploadData();
                };

            clearofflineDataElement = new ImageStringElement(LocalString.GetString("ClearOfflineData"),UIImage.FromFile("Images/ic_action_ClearOfflineData.png"));
            clearofflineDataElement.Tapped += delegate
                {
                    ClearSQLiteData();

                };

            changeOfflinePasswordElement = new ImageStringElement(LocalString.GetString("ChangeOfflinePassword"),UIImage.FromFile("Images/ic_action_OfflinePassword.png"));
            changeOfflinePasswordElement.Tapped += delegate
                {
                    // Create a VCSelectAnsprechpartnern dialog
                    vcChangeOfflinePassword = Storyboard.InstantiateViewController<VCChangeOfflinePasswordAlt>();
                    vcChangeOfflinePassword.VCSettings = this;
                    vcChangeOfflinePassword.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;

                    PresentViewController(vcChangeOfflinePassword, true, null);

                };
            gunThemeElement = new BooleanElement("Plus Theme",Application.GunTheme);
            gunThemeElement.ValueChanged += (object sender, EventArgs e) => {
                if (gunThemeElement.Value == true)
                    BusinessLayer.User.SetGunTheme(1);
                else
                    BusinessLayer.User.SetGunTheme(0);
            };
            SaveNothingElement = new RadioElement (LocalString.GetString("SaveNothing"), "LoginDateiSpeichern");
            SaveNothingElement.Tapped += delegate
                {
                    BusinessLayer.User.SetLoginSaveOption("0");
                    Application._user.SaveOnlineUserData();
                };
            SaveMandantElement = new RadioElement (LocalString.GetString("SaveNameMandant"), "LoginDateiSpeichern");
            SaveMandantElement.Tapped += delegate
                {
                    BusinessLayer.User.SetLoginSaveOption("1");
                    Application._user.SaveOnlineUserData();
                };
            SaveAllElement = new RadioElement (LocalString.GetString("SaveAll"), "LoginDateiSpeichern");
            SaveAllElement.Tapped += delegate
                {
                    BusinessLayer.User.SetLoginSaveOption("2");
                    Application._user.SaveOnlineUserData();
                };
            logElement = new ImageStringElement("Logs",UIImage.FromFile("Images/ic_action_Log.png"));
            logElement.Tapped += delegate
                {
                    // Create a VCSelectAnsprechpartnern dialog
                    vcLog = Storyboard.InstantiateViewController<VCLogs>();
                    List<BusinessLayer.Log> logs = BusinessLayer.Log.GetLogs();
                    vcLog._logs = logs;
                    PresentViewController(vcLog, true, null);

                };
            LicenseElement = new StringElement(Application.licenseKey.rec.ValueData.ToString().Split(new String[]{"-<>-"},StringSplitOptions.RemoveEmptyEntries)[0]);

            NetworkSection = new Section(LocalString.GetString("NetworkConnectivity"))
                {
                    urlElement,onlineElement
                };

            OfflineDataSection = new Section(LocalString.GetString("OfflineData"))
                {
                    changeOfflinePasswordElement ,uploadDataElement,clearofflineDataElement 

                };
            AppearenceSection = new Section(LocalString.GetString("Appearence"))
                {
                    gunThemeElement
                };
            LogSection = new Section("Logs")
                {
                    logElement
                };
            SecuritySection = new Section(LocalString.GetString("Security"))
                {
                    new RootElement(LocalString.GetString("LoginDateiSpeichern"), new RadioGroup("LoginDateiSpeichern", Convert.ToInt32(BusinessLayer.User.GetLoginSaveOption())))
                    {
                        new Section()
                        {
                            SaveNothingElement, SaveMandantElement, SaveAllElement
                        }
                    }
                };

            LicenseSection = new Section("Device ID")
                {
                    LicenseElement
                };
            taskElement = new RootElement ("TestRootElement"){NetworkSection,OfflineDataSection , AppearenceSection, SecuritySection, LogSection ,LicenseSection

            };


            this.Root.Add(taskElement);
            //            onlineElement.GetActiveCell().SelectionStyle = UITableViewCellSelectionStyle.None;

            Console.WriteLine("First Constr");

        }
        private void UploadData()
        {
            if (Application._user.NetworkStatus == DataAccessLayer.NetworkState.Disconnected)
                return;

            string text = "";
            offlineTasks = BusinessLayer.Task.HasNewOfflineTasks();

            if (offlineTasks == 0)
            {
                MessageBox.ShowErrorMessage(this.View, LocalString.GetString("NoUpload"));
                return;
            }
            else if(offlineTasks == 1)
                text = LocalString.GetString("AskUpload");
            else
                text = LocalString.GetString("AskUploads");

            UIAlertView alert = new UIAlertView (LocalString.GetString("OfflineData"),String.Format( text,offlineTasks) ,null, LocalString.GetString("Yes"),LocalString.GetString("No"));
            alert.Clicked += (object sender, UIButtonEventArgs e) => {
                if (e.ButtonIndex ==0)
                {
                    // Upload the unsync data from the SQLite Database to the SOA
                    List<BusinessLayer.Task> tasks = BusinessLayer.Task.UploadOfflineTasks(Application._user);

                    // Show the result of the process to the user
                    string message = "";
                    if (offlineTasks == 1)
                        message = String.Format( LocalString.GetString("UploadResultText"),tasks.Count , offlineTasks);
                    else
                        message = String.Format( LocalString.GetString("UploadResultsText"),tasks.Count, offlineTasks);

                    string UploadLabel = "";
                    uploadDataElement = new ImageStringElement(LocalString.GetString("UploadData") + UploadLabel,UIImage.FromFile("Images/ic_action_upload.png"));

                    OfflineDataSection.RemoveRange(1,3);
                    OfflineDataSection.Add(uploadDataElement);
                    OfflineDataSection.Add(clearofflineDataElement);

                    offlineTasks = 0;

                    MessageBox.ShowMessage(this.View,message);
                }
                else
                {

                }
            };
            alert.Show();

        }