public override void ViewDidLoad() { base.ViewDidLoad(); this.OkayBtn.Clicked += (sender, e) => { DismissViewController(true, null); // get & parse params this.YourWeightTF.ResignFirstResponder(); string your_w = this.YourWeightTF.Text; string desire_w = this.DesireWeightTF.Text; m_my_weight = System.Convert.ToInt32(your_w, 10); int goal_diff = m_my_weight - System.Convert.ToInt32(desire_w, 10); int a_days = System.Convert.ToInt32(this.AtackTF.Text, 10); // clear prev schedule ScheduleManager.DeleteAllScheduleRecords(); // calculate and save schedule(attack& cruise for now) List <ScheduleRecord> recs_list = ScheduleMaker.makeAttackCruise(goal_diff, a_days, DateTime.Now.Date); foreach (var sch in recs_list) { sch.m_weight = m_my_weight; ScheduleManager.SaveScheduleRecord(sch); } PrefsRecord pref = PrefsManager.GetPrefsRecordValue("isDietStarted"); pref.PrefValue = "1"; // diet have started PrefsManager.UpdatePrefsRecord(pref); }; }
internal static int SortByType(PrefsRecord n1, PrefsRecord n2) { int result = string.CompareOrdinal(n1.DisplayType, n2.DisplayType); if (result == 0) { return(SortByNameAscending(n1, n2)); } return(result); }
private void ShowOtherMenu(PrefsRecord record) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy to clipboard"), false, () => { EditorGUIUtility.systemCopyBuffer = record.ToString(); }); menu.ShowAsContext(); }
internal static int SortByObscurance(PrefsRecord n1, PrefsRecord n2) { int result = n1.Obscured.CompareTo(n2.Obscured); if (result == 0) { return(SortByNameAscending(n1, n2)); } return(result); }
// This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // Copy the database across (if it doesn't exist) var appdir = NSBundle.MainBundle.ResourcePath; var seedFile = Path.Combine(appdir, "Base/DukappDB.db3"); if (!File.Exists(DukappCore.DAL.DukappRepository.DatabaseFilePath)) { File.Copy(seedFile, DukappCore.DAL.DukappRepository.DatabaseFilePath); } // create a new window instance based on the screen size DukappCore.DAL.DukappRepository.Open(); RectangleF mrect = UIScreen.MainScreen.Bounds; window = new UIWindow(mrect); home_scr = new HomeVC(); RectangleF rct = home_scr.View.Bounds; var rootNavigationController = new UINavigationController(); rootNavigationController.NavigationBarHidden = true; rootNavigationController.NavigationBar.BarStyle = UIBarStyle.Black; rootNavigationController.PushViewController(home_scr, true); window.RootViewController = rootNavigationController; app.SetStatusBarStyle(UIStatusBarStyle.LightContent, true); // window.RootViewController = home_scr; // make the window visible window.MakeKeyAndVisible(); PrefsRecord rec = PrefsManager.GetPrefsRecordValue("isDietStarted"); if (rec.PrefValue == "0") { welcome_scr = new WelcomeVC(home_scr); //rootNavigationController.PushViewController(welcome_scr, true); home_scr.PresentViewController(welcome_scr, true, null); } return(true); }
internal static int SortByNameDescending(PrefsRecord n1, PrefsRecord n2) { int result = string.CompareOrdinal(n2.key, n1.key); return(result); }
internal static int SortByNameAscending(PrefsRecord n1, PrefsRecord n2) { return(string.CompareOrdinal(n1.key, n2.key)); }
protected void DrawRecord(int recordIndex, out bool recordRemoved) { recordRemoved = false; PrefsRecord record = filteredRecords[recordIndex]; ActEditorGUI.Separator(); using (ActEditorGUI.Horizontal(ActEditorGUI.PanelWithBackground)) { if (GUILayout.Button(new GUIContent("X", "Delete this pref."), ActEditorGUI.CompactButton, GUILayout.Width(20))) { record.Delete(); allRecords.Remove(record); filteredRecords.Remove(record); recordRemoved = true; return; } GUI.enabled = record.dirtyValue || record.dirtyKey && record.prefType != PrefsRecord.PrefsType.Unknown; if (GUILayout.Button(new GUIContent("S", "Save changes in this pref."), ActEditorGUI.CompactButton, GUILayout.Width(20))) { record.Save(); GUIUtility.keyboardControl = 0; } GUI.enabled = true; GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown; if (record.Obscured) { GUI.enabled &= record.obscuredType == ObscuredPrefs.DataType.String || record.obscuredType == ObscuredPrefs.DataType.Int || record.obscuredType == ObscuredPrefs.DataType.Float; if (GUILayout.Button(new GUIContent("D", "Decrypt this pref using ObscuredPrefs"), ActEditorGUI.CompactButton, GUILayout.Width(25))) { record.Decrypt(); GUIUtility.keyboardControl = 0; } } else { if (GUILayout.Button(new GUIContent("E", "Encrypt this pref using ObscuredPrefs"), ActEditorGUI.CompactButton, GUILayout.Width(25))) { record.Encrypt(); GUIUtility.keyboardControl = 0; } } GUI.enabled = true; if (GUILayout.Button(new GUIContent("...", "Other operations"), ActEditorGUI.CompactButton, GUILayout.Width(25))) { ShowOtherMenu(record); } Color guiColor = GUI.color; if (record.Obscured) { GUI.color = obscuredColor; } GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown; if (record.Obscured && !(record.obscuredType == ObscuredPrefs.DataType.String || record.obscuredType == ObscuredPrefs.DataType.Int || record.obscuredType == ObscuredPrefs.DataType.Float)) { GUI.enabled = false; EditorGUILayout.TextField(record.Key, GUILayout.MaxWidth(200), GUILayout.MinWidth(50)); GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown; } else { record.Key = EditorGUILayout.TextField(record.Key, GUILayout.MaxWidth(200), GUILayout.MinWidth(50)); } if ((record.prefType == PrefsRecord.PrefsType.String && !record.Obscured) || (record.Obscured && record.obscuredType == ObscuredPrefs.DataType.String)) { // to avoid TextMeshGenerator error because of too much characters if (record.StringValue.Length > 16382) { GUI.enabled = false; EditorGUILayout.TextField(STRING_TOO_LONG, GUILayout.MinWidth(150)); GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown; } else { record.StringValue = EditorGUILayout.TextField(record.StringValue, GUILayout.MinWidth(150)); } } else if (record.prefType == PrefsRecord.PrefsType.Int || (record.Obscured && record.obscuredType == ObscuredPrefs.DataType.Int)) { record.IntValue = EditorGUILayout.IntField(record.IntValue, GUILayout.MinWidth(150)); } else if (record.prefType == PrefsRecord.PrefsType.Float || (record.Obscured && record.obscuredType == ObscuredPrefs.DataType.Float)) { record.FloatValue = EditorGUILayout.FloatField(record.FloatValue, GUILayout.MinWidth(150)); } else if (record.Obscured) { GUI.enabled = false; EditorGUILayout.TextField(UNSUPPORTED_VALUE_DESCRIPTION, GUILayout.MinWidth(150)); GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown; } else { GUI.enabled = false; EditorGUILayout.TextField(UNKNOWN_VALUE_DESCRIPTION, GUILayout.MinWidth(150)); GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown; } GUI.color = guiColor; GUI.enabled = true; EditorGUILayout.LabelField(record.DisplayType, GUILayout.Width(70)); } }
// ---------------------------------------------------------------------------- // GUI // ---------------------------------------------------------------------------- private void OnGUI() { if (allRecords == null) { allRecords = new List <PrefsRecord>(); } if (filteredRecords == null) { filteredRecords = new List <PrefsRecord>(); } using (ActEditorGUI.Horizontal(ActEditorGUI.Toolbar)) { if (GUILayout.Button(new GUIContent("+", "Create new prefs record."), EditorStyles.toolbarButton, GUILayout.Width(20))) { addingNewRecord = true; } if (GUILayout.Button(new GUIContent("Refresh", "Re-read and re-parse all prefs."), EditorStyles.toolbarButton, GUILayout.Width(50))) { RefreshData(); GUIUtility.keyboardControl = 0; scrollPosition = Vector2.zero; recordsCurrentPage = 0; } EditorGUI.BeginChangeCheck(); sortingType = (SortingType)EditorGUILayout.EnumPopup(sortingType, EditorStyles.toolbarDropDown, GUILayout.Width(110)); if (EditorGUI.EndChangeCheck()) { ApplySorting(); } GUILayout.Space(10); EditorGUI.BeginChangeCheck(); searchPattern = ActEditorGUI.SearchToolbar(searchPattern); if (EditorGUI.EndChangeCheck()) { ApplyFiltering(); } EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 80; GUILayout.Label(new GUIContent("Crypto key", "ObscuredPrefs crypto key to use."), ActEditorGUI.ToolbarLabel, GUILayout.ExpandWidth(false)); string newKey = EditorGUILayout.TextField(ObscuredPrefs.CryptoKey, EditorStyles.toolbarTextField, GUILayout.ExpandWidth(true)); EditorGUIUtility.labelWidth = 0; if (EditorGUI.EndChangeCheck()) { ObscuredPrefs.CryptoKey = newKey; } } if (addingNewRecord) { using (ActEditorGUI.Horizontal(ActEditorGUI.PanelWithBackground)) { string[] types = { "String", "Int", "Float" }; newRecordType = EditorGUILayout.Popup(newRecordType, types, GUILayout.Width(50)); newRecordEncrypted = GUILayout.Toggle(newRecordEncrypted, new GUIContent("E", "Create new pref as encrypted ObscuredPref?"), ActEditorGUI.CompactButton, GUILayout.Width(25)); Color guiColor = GUI.color; if (newRecordEncrypted) { GUI.color = obscuredColor; } GUILayout.Label("Key:", GUILayout.ExpandWidth(false)); newRecordKey = EditorGUILayout.TextField(newRecordKey); GUILayout.Label("Value:", GUILayout.ExpandWidth(false)); if (newRecordType == 0) { newRecordStringValue = EditorGUILayout.TextField(newRecordStringValue); } else if (newRecordType == 1) { newRecordIntValue = EditorGUILayout.IntField(newRecordIntValue); } else { newRecordFloatValue = EditorGUILayout.FloatField(newRecordFloatValue); } GUI.color = guiColor; if (GUILayout.Button("OK", ActEditorGUI.CompactButton, GUILayout.Width(30))) { if (string.IsNullOrEmpty(newRecordKey) || (newRecordType == 0 && string.IsNullOrEmpty(newRecordStringValue)) || (newRecordType == 1 && newRecordIntValue == 0) || (newRecordType == 2 && Math.Abs(newRecordFloatValue) < 0.00000001f)) { ShowNotification(new GUIContent("Please fill in the pref first!")); } else { PrefsRecord newRecord; if (newRecordType == 0) { newRecord = new PrefsRecord(newRecordKey, newRecordStringValue, newRecordEncrypted); } else if (newRecordType == 1) { newRecord = new PrefsRecord(newRecordKey, newRecordIntValue, newRecordEncrypted); } else { newRecord = new PrefsRecord(newRecordKey, newRecordFloatValue, newRecordEncrypted); } if (newRecord.Save()) { allRecords.Add(newRecord); ApplySorting(); CloseNewRecordPanel(); } } } if (GUILayout.Button("Cancel", ActEditorGUI.CompactButton, GUILayout.Width(60))) { CloseNewRecordPanel(); } } } using (ActEditorGUI.Vertical(ActEditorGUI.PanelWithBackground)) { GUILayout.Space(5); DrawRecordsPages(); GUILayout.Space(5); GUI.enabled = filteredRecords.Count > 0; using (ActEditorGUI.Horizontal()) { if (GUILayout.Button("Encrypt ALL", ActEditorGUI.CompactButton)) { if (EditorUtility.DisplayDialog("Obscure ALL prefs in list?", "This will apply obscuration to ALL unobscured prefs in the list.\nAre you sure you wish to do this?", "Yep", "Oh, no!")) { foreach (PrefsRecord record in filteredRecords) { record.Encrypt(); } GUIUtility.keyboardControl = 0; ApplySorting(); } } if (GUILayout.Button("Decrypt ALL", ActEditorGUI.CompactButton)) { if (EditorUtility.DisplayDialog("UnObscure ALL prefs in list?", "This will remove obscuration from ALL obscured prefs in the list if possible.\nAre you sure you wish to do this?", "Yep", "Oh, no!")) { foreach (PrefsRecord record in filteredRecords) { record.Decrypt(); } GUIUtility.keyboardControl = 0; ApplySorting(); } } if (GUILayout.Button("Save ALL", ActEditorGUI.CompactButton)) { if (EditorUtility.DisplayDialog("Save changes to ALL prefs in list?", "Are you sure you wish to save changes to ALL prefs in the list? This can't be undone!", "Yep", "Oh, no!")) { foreach (PrefsRecord record in filteredRecords) { record.Save(); } GUIUtility.keyboardControl = 0; ApplySorting(); } } if (GUILayout.Button("Delete ALL", ActEditorGUI.CompactButton)) { if (EditorUtility.DisplayDialog("Delete ALL prefs in list?", "Are you sure you wish to delete the ALL prefs in the list? This can't be undone!", "Yep", "Oh, no!")) { foreach (PrefsRecord record in filteredRecords) { record.Delete(); } RefreshData(); GUIUtility.keyboardControl = 0; } } } GUI.enabled = true; } }
public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("Images/png/[email protected]")); this.TitleImage.Image = UIImage.FromFile("images/png/divisions/[email protected]"); this.HomeBtn.SetBackgroundImage(UIImage.FromFile("images/png/[email protected]"), UIControlState.Normal); // get if notifs enabled PrefsRecord rec = PrefsManager.GetPrefsRecordValue("NotifDate"); if (rec.PrefValue != "0" && UIApplication.SharedApplication.ScheduledLocalNotifications.GetLength(0) > 0) { m_notifTime = UIApplication.SharedApplication.ScheduledLocalNotifications[0].FireDate; this.EnableDiarySw.On = true; EnableDiaryControls(true); } else { m_notifTime = NSDate.Now; EnableDiaryControls(false); } this.TimePicker.Date = m_notifTime; this.HoursTb.Text = NSDateToDateTime(m_notifTime).ToString("HH:mm"); this.OnResetHistory.TouchUpInside += async(sender, e) => { int button = await ShowAlert("Сброс истории", "Вы уверены?", "Да", "Нет"); if (button == 0) { PrefsRecord pref = PrefsManager.GetPrefsRecordValue("isDietStarted"); pref.PrefValue = "0"; PrefsManager.UpdatePrefsRecord(pref); PrefsManager.ClearHistory(); if (prefs_scr == null) { prefs_scr = new PrefsVC(); } PresentViewController(prefs_scr, true, null); } }; this.HomeBtn.TouchUpInside += (sender, e) => { this.NavigationController.PopToRootViewController(true); }; this.HoursTb.Started += (sender, e) => { this.HoursTb.EndEditing(true); }; this.HoursTb.TouchDown += (sender, e) => { this.TimePicker.Hidden = false; this.SetTimeBtn.Hidden = false; //this.HoursTb.UserInteractionEnabled = false; }; this.EnableDiarySw.TouchUpInside += (sender, e) => { EnableDiaryControls(this.EnableDiarySw.On); EnableDiaryNotification(this.EnableDiarySw.On); PrefsRecord pref = PrefsManager.GetPrefsRecordValue("NotifDate"); pref.PrefValue = this.EnableDiarySw.On == true ? "1":"0"; PrefsManager.UpdatePrefsRecord(pref); this.TimePicker.Hidden = true; this.SetTimeBtn.Hidden = true; }; this.SetTimeBtn.TouchUpInside += (sender, e) => { m_notifTime = this.TimePicker.Date; DateTime date = NSDateToDateTime(m_notifTime); this.HoursTb.Text = date.ToString("HH:mm"); this.SetTimeBtn.Hidden = true; EnableDiaryNotification(true); this.TimePicker.Hidden = true; this.HoursTb.EndEditing(true); }; }
private void ShowOtherMenu(PrefsRecord record) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy to clipboard"), false, () => { EditorGUIUtility.systemCopyBuffer = record.ToString(); }); if (record.Obscured) { menu.AddItem(new GUIContent("Copy obscured raw data to clipboard"), false, () => { EditorGUIUtility.systemCopyBuffer = record.ToString(true); }); } var valueToPaste = EditorGUIUtility.systemCopyBuffer; switch (record.prefType) { case PrefsRecord.PrefsType.Unknown: break; case PrefsRecord.PrefsType.String: if (!record.Obscured || record.IsEditableObscuredValue()) { menu.AddItem(new GUIContent("Paste string value from clipboard"), false, () => { record.StringValue = valueToPaste; }); } break; case PrefsRecord.PrefsType.Int: menu.AddItem(new GUIContent("Paste int value from clipboard"), false, () => { int pastedInt; if (int.TryParse(valueToPaste, out pastedInt)) { record.IntValue = pastedInt; } else { Debug.LogWarning(ACTkEditorGlobalStuff.LogPrefix + "Can't paste this value to Int pref:\n" + valueToPaste); } }); break; case PrefsRecord.PrefsType.Float: menu.AddItem(new GUIContent("Paste float value from clipboard"), false, () => { float pastedFloat; if (float.TryParse(valueToPaste, out pastedFloat)) { record.FloatValue = pastedFloat; } else { Debug.LogWarning(ACTkEditorGlobalStuff.LogPrefix + "Can't paste this value to Float pref:\n" + valueToPaste); } }); break; default: throw new ArgumentOutOfRangeException(); } menu.ShowAsContext(); }
public static int UpdatePrefsRecord(PrefsRecord item) { return(instance.db.SaveItem <PrefsRecord>(item)); }
private void OnGUI() { if (allRecords == null) { allRecords = new List <PrefsRecord>(); } if (filteredRecords == null) { filteredRecords = new List <PrefsRecord>(); } using (CustomEditorGUI.Horizontal(CustomEditorGUI.Toolbar)) { if (GUILayout.Button(new GUIContent("+", "Create new prefs record."), EditorStyles.toolbarButton, GUILayout.Width(20))) { addingNewRecord = true; } if (GUILayout.Button(new GUIContent("Refresh", "Re-read and re-parse all prefs."), EditorStyles.toolbarButton, GUILayout.Width(50))) { RefreshData(); GUIUtility.keyboardControl = 0; scrollPosition = Vector2.zero; recordsCurrentPage = 0; } EditorGUI.BeginChangeCheck(); sortingType = (SortingType)EditorGUILayout.EnumPopup(sortingType, EditorStyles.toolbarDropDown, GUILayout.Width(110)); if (EditorGUI.EndChangeCheck()) { ApplySorting(); } GUILayout.Space(10); EditorGUI.BeginChangeCheck(); searchPattern = CustomEditorGUI.SearchToolbar(searchPattern); if (EditorGUI.EndChangeCheck()) { ApplyFiltering(); } } if (addingNewRecord) { using (CustomEditorGUI.Horizontal(CustomEditorGUI.PanelWithBackground)) { string[] types = { "String", "Int", "Float" }; newRecordType = EditorGUILayout.Popup(newRecordType, types, GUILayout.Width(50)); Color guiColor = GUI.color; GUILayout.Label("Key:", GUILayout.ExpandWidth(false)); newRecordKey = EditorGUILayout.TextField(newRecordKey); GUILayout.Label("Value:", GUILayout.ExpandWidth(false)); if (newRecordType == 0) { newRecordStringValue = EditorGUILayout.TextField(newRecordStringValue); } else if (newRecordType == 1) { newRecordIntValue = EditorGUILayout.IntField(newRecordIntValue); } else { newRecordFloatValue = EditorGUILayout.FloatField(newRecordFloatValue); } GUI.color = guiColor; if (GUILayout.Button("OK", CustomEditorGUI.CompactButton, GUILayout.Width(30))) { if (string.IsNullOrEmpty(newRecordKey) || (newRecordType == 0 && string.IsNullOrEmpty(newRecordStringValue)) || (newRecordType == 1 && newRecordIntValue == 0) || (newRecordType == 2 && Math.Abs(newRecordFloatValue) < 0.00000001f)) { ShowNotification(new GUIContent("Please fill in the pref first!")); } else { PrefsRecord newRecord; if (newRecordType == 0) { newRecord = new PrefsRecord(newRecordKey, newRecordStringValue); } else if (newRecordType == 1) { newRecord = new PrefsRecord(newRecordKey, newRecordIntValue); } else { newRecord = new PrefsRecord(newRecordKey, newRecordFloatValue); } if (newRecord.Save()) { allRecords.Add(newRecord); ApplySorting(); CloseNewRecordPanel(); } } } if (GUILayout.Button("Cancel", CustomEditorGUI.CompactButton, GUILayout.Width(60))) { CloseNewRecordPanel(); } } } using (CustomEditorGUI.Vertical(CustomEditorGUI.PanelWithBackground)) { GUILayout.Space(5); DrawRecordsPages(); GUILayout.Space(5); } }
public static int UpdatePrefsRecord(PrefsRecord item) { return(DukappCore.DAL.DukappRepository.UpdatePrefsRecord(item)); }