Example #1
0
        private void LoadComments(Section section)
        {
            section.Clear();
            if (_comments == null)
            {
                return;
            }

            foreach (var comment in _comments)
            {
                try
                {
                    var thisComment = comment;
                    var sse         = new Gistacular.Elements.NameTimeStringElement()
                    {
                        Time   = thisComment.CreatedAt,
                        String = thisComment.Body,
                        Lines  = 4,
                        Image  = Images.Misc.Anonymous,
                    };

                    sse.Name     = thisComment.User == null ? "Unknown" : thisComment.User.Login;
                    sse.ImageUri = (thisComment.User == null) ? null : new Uri(thisComment.User.AvatarUrl);
                    section.Add(sse);
                }
                catch (Exception e)
                {
                    Utilities.LogException("Unable to load comments!", e);
                }
            }
        }
Example #2
0
        private void LoadForks(Section section)
        {
            section.Clear();
            if (Model == null || Model.Forks == null)
            {
                return;
            }

            foreach (var fork in Model.Forks)
            {
                try
                {
                    var sse = new SubcaptionElement(fork.User.Login, fork.CreatedAt.ToDaysAgo())
                    {
                        Accessory     = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
                        LineBreakMode = MonoTouch.UIKit.UILineBreakMode.TailTruncation,
                        Lines         = 1,
                    };

                    sse.Image    = Images.Misc.Anonymous;
                    sse.ImageUri = new Uri(fork.User.AvatarUrl);

                    var id = fork.Url.Substring(fork.Url.LastIndexOf('/') + 1);
                    sse.Tapped += () => NavigationController.PushViewController(new GistInfoController(id), true);
                    section.Add(sse);
                }
                catch (Exception e)
                {
                    Utilities.LogException("Unable to load forks!", e);
                }
            }
        }
Example #3
0
        private void LoadFiles(Section section)
        {
            section.Clear();
            if (Model == null || Model.Files == null)
            {
                return;
            }

            foreach (var file in Model.Files.Keys.OrderBy(x => x))
            {
                try
                {
                    var sse = new SubcaptionElement(file, Model.Files[file].Size + " bytes")
                    {
                        Accessory     = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
                        LineBreakMode = MonoTouch.UIKit.UILineBreakMode.TailTruncation,
                        Lines         = 1
                    };

                    var fileSaved = file;
                    sse.Tapped += () => NavigationController.PushViewController(new GistFileController(Model.Files[fileSaved]), true);
                    section.Add(sse);
                }
                catch (Exception e)
                {
                    Utilities.LogException("Unable to load files!", e);
                }
            }
        }
Example #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var section = new Section();
            var source  = new DialogTableViewSource(TableView);

            TableView.Source          = source;
            TableView.TableFooterView = new UIView();

            source.Root.Add(new Section {
                _titleElement
            }, section, new Section {
                _descriptionElement
            });

            this.WhenAnyValue(x => x.ViewModel.IsCollaborator)
            .Where(x => x.HasValue && x.Value)
            .Where(_ => _milestoneElement.Section == null)
            .Subscribe(x => section.Add(new [] { _assigneeElement, _milestoneElement, _labelsElement }));

            this.WhenAnyValue(x => x.ViewModel.IsCollaborator)
            .Where(x => !x.HasValue || !x.Value)
            .Subscribe(x => section.Clear());
        }
Example #5
0
        void SomethingHappened()
        {
            section_devices.Clear();
            section_devices.Add(new StringElement(ble.State));

            while (root_element.Count > 1)
            {
                root_element.RemoveAt(1);
            }
            root_element.TableView.BeginUpdates();
            foreach (var device in ble.Devices.Values)
            {
                var section = new Section(device.Name);
                section.Add(new StringElement(device.State));
                section.Add(new StringElement(device.Uuid));

                if (device.Services != null)
                {
                    foreach (var service in device.Services)
                    {
                        section.Add(new StringElement(string.Format("Service: {0}", service.Name)));
                    }
                }

                root_element.Add(section);
            }
            root_element.TableView.EndUpdates();
        }
Example #6
0
        public GistCreateView()
        {
            HeaderView.Image = Images.LoginUserUnknown;

            this.WhenAnyValue(x => x.ViewModel.SaveCommand)
            .Select(x => x.ToBarButtonItem(UIBarButtonSystemItem.Save))
            .Subscribe(x => NavigationItem.RightBarButtonItem = x);

            this.WhenAnyValue(x => x.ViewModel.CurrentAccount).Subscribe(x =>
            {
                HeaderView.SubText  = x.Username;
                HeaderView.ImageUri = x.AvatarUrl;
            });

            _publicElement = new BooleanElement("Public", false, (e) => ViewModel.IsPublic = e.Value);
            this.WhenAnyValue(x => x.ViewModel.IsPublic).Subscribe(x => _publicElement.Value = x);

            _descriptionElement         = new MultilinedElement("Description");
            _descriptionElement.Tapped += ChangeDescription;
            this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => _descriptionElement.Value = x);

            _fileSection = new Section(null, new TableFooterButton("Add File", () => ViewModel.AddGistFileCommand.ExecuteIfCan()));
            this.WhenAnyValue(x => x.ViewModel.Files).Subscribe(x =>
            {
                if (x == null)
                {
                    _fileSection.Clear();
                    return;
                }

                var elements = new List <Element>();
                foreach (var file in x.Keys)
                {
                    var key = file;
                    if (string.IsNullOrEmpty(ViewModel.Files[file]))
                    {
                        continue;
                    }

                    var size = System.Text.Encoding.UTF8.GetByteCount(ViewModel.Files[file]);
                    var el   = new StyledStringElement(file, size + " bytes", UITableViewCellStyle.Subtitle)
                    {
                        Accessory = UITableViewCellAccessory.DisclosureIndicator,
                        Image     = Images.FileCode
                    };

                    el.Tapped += () => ViewModel.ModifyGistFileCommand.ExecuteIfCan(key);
                    elements.Add(el);
                }

                _fileSection.Reset(elements);
            });
        }
        void Sync()
        {
            Console.WriteLine("[AppDelegate] Sync");

            var list = _downloader.List();

            _downloads.Clear();

            foreach (var item in list)
            {
                Add(item.Url);
            }
        }
Example #8
0
 private void PersistentObjectChanged(PersistentObject obj)
 {
     if (IsViewLoaded)
     {
         if (obj.GetType() == typeof(UserCredentials))
         {
             if (_ownTimetable == null)
             {
                 _ownTimetable = new StyledStringElement(ApplicationSettings.Instance.UserCredentials.Name, OnOwnTapped)
                 {
                     Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator
                 };
                 Root.Add(new Section("Eigener Stundenplan")
                 {
                     _ownTimetable
                 });
             }
             else
             {
                 _ownTimetable.Caption = ApplicationSettings.Instance.UserCredentials.Name;
             }
         }
         else if (obj.GetType() == typeof(UserTimetableList))
         {
             if (_otherTimetables == null)
             {
                 _otherTimetables = new Section("Andere Stundenpläne");
                 Root.Add(_otherTimetables);
             }
             if (!obj.Equals(_loadedList))
             {
                 _otherTimetables.Clear();
                 foreach (var o in ApplicationSettings.Instance.UserTimetablelist.Usernames)
                 {
                     var tmp = o;
                     _otherTimetables.Add(new StyledStringElement(o, () => {
                         OnTapped(tmp);
                     })
                     {
                         Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator
                     });
                 }
                 _loadedList = new UserTimetableList()
                 {
                     Usernames = new ObservableCollection <string>((obj as UserTimetableList).Usernames)
                 };
             }
         }
         this.ReloadData();
     }
 }
Example #9
0
        private void CreateEditableSection(bool editable)
        {
            var elementList = new List <Element>(_usernameSection.Elements);

            _usernameSection.Clear();
            foreach (var element in elementList)
            {
                if (element is StringElement)
                {
                    _usernameSection.Add(CreateEditableElement((elementList.IndexOf(element) + 1).ToString(), (element as StringElement).Caption, editable));
                }
                else
                {
                    _usernameSection.Add(CreateEditableElement(element.Caption, (element as EntryElement).Value ?? (elementList.IndexOf(element) + 1).ToString(), editable));
                    ApplicationSettings.Instance.UserTimetablelist.Usernames [elementList.IndexOf(element)] = (element as EntryElement).Value ?? (elementList.IndexOf(element) + 1).ToString();
                }
            }
        }
Example #10
0
        public void CreateAddOrderScreen(Section section)
        {
            section.Clear();

            foreach (var position in CurrentOrder.Positions)
            {
                StringElement positionName = new StringElement(position.Name);

                section.Add(positionName);
            }

            StringElement addPositionElement = new StringElement("+Positions");

            addPositionElement.Tapped += () =>
            {
                CreateAddPositionScreen(section);
            };

            section.Add(addPositionElement);

            StringElement doneElement = new StringElement("Done");

            doneElement.Tapped += () =>
            {
                if (CurrentOrder.Positions.Count > 0)
                {
                    CurrentOrder.Date = DateTime.Now;

                    Database.Insert(CurrentOrder);

                    int lastId = Database.ExecuteScalar <int>(@"select last_insert_rowid()");

                    foreach (var position in CurrentOrder.Positions)
                    {
                        position.OrderId = lastId;
                        Database.Insert(position);
                    }

                    NavigationController.PopViewController(true);
                }
            };

            section.Add(doneElement);
        }
Example #11
0
        async public void Refresh()
        {
            textSection.Clear();
            NetAtmo.Gadget gadget = new NetAtmo.Gadget(Config.Id, Config.Secret, Config.UserName, Config.Password);
            if (await gadget.ClientCredentials.ExecuteAsync())
            {
                textSection.Add(new StringElement("RefreshToken {0}", gadget.ClientCredentials.Executed.Result.Data.RefreshToken.ToString()));
                textSection.Add(new StringElement("AccessToken {0}", gadget.ClientCredentials.Executed.Result.Data.AccessToken.ToString()));
                if (await gadget.DeviceList.ExecuteAsync())
                {
                    foreach (var device in gadget.DeviceList.Executed.Result.Data.Body.Devices)
                    {
                        textSection.Add(new  StringElement("Station", device.StationName));
                    }

                    foreach (var device in gadget.DeviceList.Executed.Result.Data.Body.Devices)
                    {
                        textSection.Add(new StringElement(device.ModuleName, device.DashboardData.Temperature.ToString()));
                    }

                    foreach (var module in gadget.DeviceList.Executed.Result.Data.Body.Modules)
                    {
                        textSection.Add(new StringElement(module.ModuleName, module.DashboardData.Temperature.ToString()));
                    }
                }
                else if (gadget.DeviceList.Executed.IsException)
                {
                    textSection.Add(new StringElement("Exception gadget.DeviceList {0}", gadget.DeviceList.Executed.Exception.ToString()));
                }
                else
                {
                    textSection.Add(new StringElement("Error gadget.DeviceList"));
                }
            }
            else if (gadget.ClientCredentials.Executed.IsException)
            {
                textSection.Add(new StringElement("Exception gadget.ClientCredentials {0}", gadget.ClientCredentials.Executed.Exception.ToString()));
            }
            else
            {
                textSection.Add(new StringElement("Error gadget.ClientCredentials"));
            }
        }
Example #12
0
        public override void ViewDidAppear(bool animated)
        {
            // trace event
            TraceHelper.AddMessage("Add: ViewDidAppear");

            if (dialogViewController == null)
            {
                InitializeComponent();
            }

            // set the background
            dialogViewController.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground);

            // initialize controls
            Name.Value = "";

            // populate the lists section dynamically
            listsSection.Clear();
            CreateAddButtons();
            // add the buttons by using Insert instead of AddAll, which allows disabling the animation
            foreach (var b in AddButtons)
            {
                if (b != null)
                {
                    listsSection.Insert(listsSection.Count, UITableViewRowAnimation.None, b);
                }
            }

            // HACK: touch the ViewControllers array to refresh it (in case the user popped the nav stack)
            // this is to work around a bug in monotouch (https://bugzilla.xamarin.com/show_bug.cgi?id=1889)
            // where the UINavigationController leaks UIViewControllers when the user pops the nav stack
            if (this.NavigationController != null && this.NavigationController.ViewControllers != null)
            {
                if (this.NavigationController.ViewControllers.Length > 0)
                {
                }
            }

            base.ViewDidAppear(animated);
        }
Example #13
0
        /// <summary>Saves this layout to the specified section.</summary>
        /// <param name="section">Configuration section.</param>
        public void SaveTo(Section section)
        {
            Verify.Argument.IsNotNull(section, nameof(section));

            section.Clear();

            _root.SaveTo(section.CreateSection("Root"));

            if (_left != null || _top != null || _right != null || _bottom != null)
            {
                var sides = section.CreateSection("Sides");
                if (_left != null)
                {
                    _left.SaveTo(sides.CreateSection("Left"));
                }
                if (_top != null)
                {
                    _top.SaveTo(sides.CreateSection("Top"));
                }
                if (_right != null)
                {
                    _right.SaveTo(sides.CreateSection("Right"));
                }
                if (_bottom != null)
                {
                    _bottom.SaveTo(sides.CreateSection("Bottom"));
                }
            }

            if (_floats != null && _floats.Count != 0)
            {
                var floats = section.CreateSection("Floats");
                for (int i = 0; i < _floats.Count; ++i)
                {
                    _floats[i].SaveTo(section.CreateSection("Float_" + i.ToString(
                                                                System.Globalization.CultureInfo.InvariantCulture)));
                }
            }
        }
 public void RefreshMarkers()
 {
     _Database.GetAllMarkersAsync().ContinueWith(task => {
         InvokeOnMainThread(() => {
             List <MarkerInfo> markerData = task.Result.OrderBy(mi => mi.Name).ToList();
             _MainSection.Clear();
             _MainSection.AddAll(markerData.Select(markerInfo => {
                 MarkerInfo currentMarkerInfo          = markerInfo;
                 StyledStringElement markerNameElement = new StyledStringElement(currentMarkerInfo.Name, () => {
                     InvokeOnMainThread(() => {
                         mapController.SetCameraPosition(currentMarkerInfo.Latitude, currentMarkerInfo.Longitude);
                         NavigationController.PushViewController(mapController, animated: true);
                     });
                 });
                 markerNameElement.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                 return(markerNameElement as Element);
             }));
             ReloadData();
             mapController.RefreshMarkers(markerData);
         });
     });
 }
Example #15
0
        void Populate()
        {
            section.Clear();
            var entries = ManagedNetstat.GetTcp();

            foreach (var entry in entries)
            {
                if (!Filter(entry))
                {
                    continue;
                }
                var text    = string.Format("{0} - {1} - {2}", entry.LocalEndpoint, entry.RemoteEndpoint, entry.State);
                var element = new StyledStringElement(text);
                element.Font = UIFont.SystemFontOfSize(12.0f);
                if (!displayedEntries.ContainsKey(entry))
                {
                    displayedEntries.Add(entry, DateTime.UtcNow);
                    element.BackgroundColor = UIColor.Red;
                }
                else
                {
                    var age = DateTime.UtcNow - displayedEntries [entry];
                    if (age < TimeSpan.FromSeconds(3))
                    {
                        element.BackgroundColor = UIColor.Yellow;
                    }
                }
                section.Add(element);
            }
            var oldEntries = displayedEntries.Keys.ToList();

            foreach (var old in oldEntries)
            {
                if (!entries.Contains(old))
                {
                    displayedEntries.Remove(old);
                }
            }
        }
Example #16
0
        public void CreateAddPositionScreen(Section section)
        {
            section.Clear();

            EntryElement nameEntry   = new EntryElement("Name", "", "");
            EntryElement priceEntry  = new EntryElement("Price", "price per unit", "");
            EntryElement amountEntry = new EntryElement("Amount", "", "");

            StringElement doneButton = new StringElement("DONE");

            doneButton.Tapped += () =>
            {
                CurrentOrder.AddPostion(new OrderPosition(0, nameEntry.Value,
                                                          Convert.ToInt32(priceEntry.Value),
                                                          Convert.ToInt32(amountEntry.Value)));

                CreateAddOrderScreen(section);
            };

            section.Add(nameEntry);
            section.Add(priceEntry);
            section.Add(amountEntry);
            section.Add(doneButton);
        }
Example #17
0
        public override void ViewWillAppear(bool animated)
        {
            if (Root.Count != 0)
            {
                if (!Utilities.UserInterfaceIdiomIsPhone)
                {
                    if (receivedDocumentsSection != null)
                    {
                        receivedDocumentsSection.Clear();
                        receivedDocumentsSection.AddAll(recent.GetElements());
                    }
                    if (transferredDocumentsSection != null)
                    {
                        transferredDocumentsSection.Clear();
                        transferredDocumentsSection.AddAll(local.GetElements());
                    }
                }
                return;
            }

            Theme.Configure("AxCrypt", this);

            receivedDocumentsSection    = new Section();
            transferredDocumentsSection = new Section();

            if (Utilities.UserInterfaceIdiomIsPhone)
            {
                receivedDocumentsSection.Add(new ThemedStringElement("Received documents", OnRecentFilesButtonTapped));
                transferredDocumentsSection.Add(new ThemedStringElement("Transferred documents", OnLocalFilesButtonTapped));

                if (Utilities.iPhone5OrPad)
                {
                    // We've got plenty of vertical space to be a little more verbose
                    receivedDocumentsSection.Footer    = "documents received from other apps";
                    transferredDocumentsSection.Footer = "documents transferred from iTunes";
                }
            }
            else
            {
                receivedDocumentsSection.Caption = "Documents received from other Apps";
                receivedDocumentsSection.Footer  = " ";
                recent           = new FileListingViewController(String.Empty, BasePath.ReceivedFilesId);
                recent.OpenFile += AppDelegate.Current.HandleOpenFile;
                receivedDocumentsSection.AddAll(recent.GetElements());

                transferredDocumentsSection.Caption = "Documents transferred via iTunes";
                transferredDocumentsSection.Footer  = " ";
                local           = new FileListingViewController(String.Empty, BasePath.TransferredFilesId);
                local.OpenFile += AppDelegate.Current.HandleOpenFile;
                transferredDocumentsSection.AddAll(local.GetElements());
            }


            Root.Add(new[] {
                receivedDocumentsSection,
                transferredDocumentsSection,
            });

            if (!Utilities.UserInterfaceIdiomIsPhone)
            {
                Root.Add(new Section(String.Empty));
            }

            Root.Add(new [] {
                new Section {
                    new ThemedStringElement("About", OnAboutButtonTapped),
                    new ThemedStringElement("Frequently Asked Questions", OnFaqButtonTapped),
                    new ThemedStringElement("Troubleshooting", OnTroubleshootingButtonTapped),
                    new ThemedStringElement("Feedback", OnFeedbackButtonTapped)
                },
            });

            TableView.ScrollEnabled = receivedDocumentsSection.Count + receivedDocumentsSection.Count > 20;
            base.ViewWillAppear(animated);
        }
Example #18
0
        public void DebugPage()
        {
            TraceHelper.AddMessage("Debug: constructor");

            // render URL and status
            var serviceUrl = new EntryElement("URL", "URL to connect to", WebServiceHelper.BaseUrl);
            var service    = new Section("Service")
            {
                serviceUrl,
                new StringElement("Store New Service URL", delegate
                {
                    serviceUrl.FetchValue();
                    // validate that this is a good URL before storing it (a bad URL can hose the phone client)
                    Uri uri = null;
                    if (Uri.TryCreate(serviceUrl.Value, UriKind.RelativeOrAbsolute, out uri) &&
                        (uri.Scheme == "http" || uri.Scheme == "https"))
                    {
                        WebServiceHelper.BaseUrl = serviceUrl.Value;
                    }
                    else
                    {
                        serviceUrl.Value = WebServiceHelper.BaseUrl;
                    }
                }),
                new StringElement("Connected", App.ViewModel.LastNetworkOperationStatus.ToString()),
            };

            // render user queue
            var userQueue = new Section("User Queue");

            userQueue.Add(new StringElement(
                              "Clear Queue",
                              delegate
            {
                RequestQueue.DeleteQueue(RequestQueue.UserQueue);
                userQueue.Clear();
            }));

            List <RequestQueue.RequestRecord> requests = RequestQueue.GetAllRequestRecords(RequestQueue.UserQueue);

            if (requests != null)
            {
                foreach (var req in requests)
                {
                    string typename;
                    string reqtype;
                    string id;
                    string name;
                    RequestQueue.RetrieveRequestInfo(req, out typename, out reqtype, out id, out name);
                    var sse = new StyledStringElement(String.Format("  {0} {1} {2} (id {3})", reqtype, typename, name, id))
                    {
                        Font = UIFont.FromName("Helvetica", UIFont.SmallSystemFontSize),
                    };
                    userQueue.Add(sse);
                }
            }

            // render system queue
            var systemQueue = new Section("System Queue");

            systemQueue.Add(new StringElement(
                                "Clear Queue",
                                delegate
            {
                RequestQueue.DeleteQueue(RequestQueue.SystemQueue);
                systemQueue.Clear();
            }));

            requests = RequestQueue.GetAllRequestRecords(RequestQueue.SystemQueue);
            if (requests != null)
            {
                foreach (var req in requests)
                {
                    string typename;
                    string reqtype;
                    string id;
                    string name;
                    RequestQueue.RetrieveRequestInfo(req, out typename, out reqtype, out id, out name);
                    var sse = new StyledStringElement(String.Format("  {0} {1} {2} (id {3})", reqtype, typename, name, id))
                    {
                        Font = UIFont.FromName("Helvetica", UIFont.SmallSystemFontSize),
                    };
                    systemQueue.Add(sse);
                }
            }

            var traceMessages = new Section("Trace Messages");

            traceMessages.Add(new StringElement(
                                  "Clear Trace",
                                  delegate
            {
                TraceHelper.ClearMessages();
                traceMessages.Clear();
            }));
            traceMessages.Add(new StringElement(
                                  "Send Trace",
                                  delegate
            {
                TraceHelper.SendMessages(App.ViewModel.User);
            }));
            foreach (var m in TraceHelper.GetMessages().Split('\n'))
            {
                // skip empty messages
                if (m == "")
                {
                    continue;
                }

                // create a new (small) string element with a detail indicator which
                // brings up a message box with the entire message
                var sse = new StyledStringElement(m)
                {
                    Accessory = UITableViewCellAccessory.DetailDisclosureButton,
                    Font      = UIFont.FromName("Helvetica", UIFont.SmallSystemFontSize),
                };
                string msg = m;                  // make a copy for the closure below
                sse.AccessoryTapped += delegate
                {
                    var alert = new UIAlertView("Detail", msg, null, "Ok");
                    alert.Show();
                };
                traceMessages.Add(sse);
            }
            ;

            var root = new RootElement("Debug")
            {
                service,
                userQueue,
                systemQueue,
                traceMessages,
            };

            var dvc = new DialogViewController(root, true);

            dvc.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground);
            this.PushViewController(dvc, true);
            //this.NavigationController.PushViewController (dvc, true);
        }
Example #19
0
        public void Generate(bool ForceRegenerate)
        {
            var s = new SlnFile();

            s.FullPath = OutputDirectory / (SolutionName + ".sln");
            using (var sr = new StringReader(SlnTemplateText))
            {
                s.Read(sr);
            }

            s.Projects.Clear();
            s.SolutionConfigurationsSection.Clear();
            s.ProjectConfigurationsSection.Clear();

            foreach (var ConfigurationType in Enum.GetValues(typeof(ConfigurationType)).Cast <ConfigurationType>())
            {
                var ConfigurationTypeAndArchitecture = $"{ConfigurationType}|{GetArchitectureString(TargetOperatingSystem, TargetArchitecture)}";
                s.SolutionConfigurationsSection.SetValue(ConfigurationTypeAndArchitecture, ConfigurationTypeAndArchitecture);
            }

            SlnSection NestedProjects = null;

            foreach (var Section in s.Sections.Where(Section => Section.Id == "NestedProjects"))
            {
                Section.Clear();
                NestedProjects = Section;
            }

            if (NestedProjects == null)
            {
                NestedProjects = new SlnSection
                {
                    Id = "NestedProjects"
                };
                s.Sections.Add(NestedProjects);
            }

            var Filters = new Dictionary <String, String>(StringComparer.OrdinalIgnoreCase);

            foreach (var Project in ProjectReferences)
            {
                var Dir = Project.VirtualDir.ToString(PathStringStyle.Windows);
                if (!Filters.ContainsKey(Dir))
                {
                    var CurrentDir       = Dir.AsPath();
                    var CurrentDirFilter = CurrentDir.ToString(PathStringStyle.Windows);
                    while ((CurrentDirFilter != ".") && !Filters.ContainsKey(CurrentDirFilter))
                    {
                        var g = Guid.ParseExact(Hash.GetHashForPath(CurrentDirFilter, 32), "N").ToString().ToUpper();
                        Filters.Add(CurrentDirFilter, g);
                        CurrentDir       = CurrentDir.Parent;
                        CurrentDirFilter = CurrentDir.ToString(PathStringStyle.Windows);
                        if (CurrentDirFilter != ".")
                        {
                            var gUpper = Guid.ParseExact(Hash.GetHashForPath(CurrentDirFilter, 32), "N").ToString().ToUpper();
                            NestedProjects.Properties.SetValue("{" + g + "}", "{" + gUpper + "}");
                        }
                    }
                }

                s.Projects.Add(new SlnProject
                {
                    TypeGuid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}",
                    Name     = Project.Name,
                    FilePath = Project.FilePath.FullPath.RelativeTo(OutputDirectory).ToString(PathStringStyle.Windows),
                    Id       = "{" + Project.Id + "}"
                });

                var conf = new SlnPropertySet("{" + Project.Id + "}");
                foreach (var c in s.SolutionConfigurationsSection)
                {
                    var Value = TargetOperatingSystem == OperatingSystemType.Windows ? c.Value.Replace("|x86", "|Win32") : c.Value;
                    conf.SetValue(c.Key + ".ActiveCfg", Value);
                    conf.SetValue(c.Key + ".Build.0", Value);
                }
                s.ProjectConfigurationsSection.Add(conf);

                if (Dir != ".")
                {
                    NestedProjects.Properties.SetValue("{" + Project.Id + "}", "{" + Filters[Dir] + "}");
                }
            }

            foreach (var f in Filters)
            {
                s.Projects.Add(new SlnProject
                {
                    TypeGuid = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    Name     = f.Key.AsPath().FileName,
                    FilePath = f.Key.AsPath().FileName,
                    Id       = "{" + f.Value + "}"
                });
            }

            foreach (var Section in s.Sections.Where(Section => Section.Id == "ExtensibilityGlobals"))
            {
                Section.Properties.SetValue("SolutionGuid", "{" + SolutionId.ToUpper() + "}");
            }

            String Text;

            using (var sw = new StringWriter())
            {
                s.Write(sw);
                Text = sw.ToString();
            }
            TextFile.WriteToFile(s.FullPath, Text, Encoding.UTF8, !ForceRegenerate);
        }
Example #20
0
 void PopulateSearchFromArray(string [] results)
 {
     savedSearches.Clear();
     savedSearches.Insert(0, UITableViewRowAnimation.None, from x in results select(Element) new SearchElement(x, x));
 }
Example #21
0
        /// <summary>Saves this layout to the specified section.</summary>
        /// <param name="section">Configuration section.</param>
        public void SaveTo(Section section)
        {
            Verify.Argument.IsNotNull(section, "section");

            section.Clear();

            _root.SaveTo(section.CreateSection("Root"));

            if(_left != null || _top != null || _right != null || _bottom != null)
            {
                var sides = section.CreateSection("Sides");
                if(_left != null)
                {
                    _left.SaveTo(sides.CreateSection("Left"));
                }
                if(_top != null)
                {
                    _top.SaveTo(sides.CreateSection("Top"));
                }
                if(_right != null)
                {
                    _right.SaveTo(sides.CreateSection("Right"));
                }
                if(_bottom != null)
                {
                    _bottom.SaveTo(sides.CreateSection("Bottom"));
                }
            }

            if(_floats != null && _floats.Count != 0)
            {
                var floats = section.CreateSection("Floats");
                for(int i = 0; i < _floats.Count; ++i)
                {
                    _floats[i].SaveTo(section.CreateSection("Float_" + i.ToString(
                        System.Globalization.CultureInfo.InvariantCulture)));
                }
            }
        }
Example #22
0
        public void Generate(bool EnableRebuild)
        {
            var s = new SlnFile();

            s.FullPath = Path.GetFullPath(Path.Combine(OutputDirectory, SolutionName + ".sln"));
            using (var sr = new StringReader(SlnTemplateText))
            {
                s.Read(sr);
            }

            s.Projects.Clear();
            s.ProjectConfigurationsSection.Clear();
            SlnSection NestedProjects = null;

            foreach (var Section in s.Sections.Where(Section => Section.Id == "NestedProjects"))
            {
                Section.Clear();
                NestedProjects = Section;
            }

            if (NestedProjects == null)
            {
                NestedProjects = new SlnSection
                {
                    Id = "NestedProjects"
                };
                s.Sections.Add(NestedProjects);
            }

            var Filters = new Dictionary <String, String>(StringComparer.OrdinalIgnoreCase);

            foreach (var Project in ProjectReferences)
            {
                var Dir = Project.VirtualDir.Replace('/', '\\');
                if (!Filters.ContainsKey(Dir))
                {
                    var CurrentDir = Dir;
                    while ((CurrentDir != "") && !Filters.ContainsKey(CurrentDir))
                    {
                        var g = Guid.ParseExact(Hash.GetHashForPath(CurrentDir, 32), "N").ToString().ToUpper();
                        Filters.Add(CurrentDir, g);
                        CurrentDir = Path.GetDirectoryName(CurrentDir);
                        if (CurrentDir != "")
                        {
                            var gUpper = Guid.ParseExact(Hash.GetHashForPath(CurrentDir, 32), "N").ToString().ToUpper();
                            NestedProjects.Properties.SetValue("{" + g + "}", "{" + gUpper + "}");
                        }
                    }
                }

                s.Projects.Add(new SlnProject
                {
                    TypeGuid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}",
                    Name     = Project.Name,
                    FilePath = FileNameHandling.GetRelativePath(Project.FilePath, OutputDirectory),
                    Id       = "{" + Project.Id + "}"
                });

                var conf = new SlnPropertySet("{" + Project.Id + "}");
                foreach (var c in s.SolutionConfigurationsSection)
                {
                    var Value = c.Value.Replace("|x86", "|Win32");
                    conf.SetValue(c.Key + ".ActiveCfg", Value);
                    conf.SetValue(c.Key + ".Build.0", Value);
                }
                s.ProjectConfigurationsSection.Add(conf);

                NestedProjects.Properties.SetValue("{" + Project.Id + "}", "{" + Filters[Dir] + "}");
            }

            foreach (var f in Filters)
            {
                s.Projects.Add(new SlnProject
                {
                    TypeGuid = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}",
                    Name     = Path.GetFileName(f.Key),
                    FilePath = Path.GetFileName(f.Key),
                    Id       = "{" + f.Value + "}"
                });
            }

            foreach (var Section in s.Sections.Where(Section => Section.Id == "ExtensibilityGlobals"))
            {
                Section.Properties.SetValue("SolutionGuid", "{" + SolutionId.ToUpper() + "}");
            }

            String Text;

            using (var sw = new StringWriter())
            {
                s.Write(sw);
                Text = sw.ToString();
            }
            TextFile.WriteToFile(s.FullPath, Text, Encoding.UTF8, !EnableRebuild);
        }
Example #23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (HeaderView != null)
            {
                HeaderView.Text = ViewModel.Username;
            }
            if (SlideUpTitle != null)
            {
                SlideUpTitle.Text = ViewModel.Username;
            }

            HeaderView.Text         = ViewModel.Username;
            HeaderView.TextColor    = UIColor.White;
            HeaderView.SubTextColor = UIColor.FromWhiteAlpha(0.9f, 1.0f);

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Images.Gear, UIBarButtonItemStyle.Plain,
                                                                    (s, e) => ViewModel.GoToSettingsCommand.ExecuteIfCan());

            ViewModel.WhenAnyValue(x => x.CanPurchase).Subscribe(x =>
            {
                if (x)
                {
                    NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Upgrade", UIBarButtonItemStyle.Plain,
                                                                           (s, e) => ViewModel.GoToPurchaseCommand.ExecuteIfCan());
                }
                else
                {
                    NavigationItem.LeftBarButtonItem = null;
                }
            });

            ViewModel.WhenAnyValue(x => x.User).Where(x => x != null).Subscribe(x =>
            {
                HeaderView.ImageUri = x.AvatarUrl;
                HeaderView.SubText  = x.Name;
                ReloadData();
            });

            var split     = new SplitButtonElement();
            var likes     = split.AddButton("Likes", "-", () => ViewModel.GoToLikesCommand.ExecuteIfCan());
            var dislikes  = split.AddButton("Dislikes", "-", () => ViewModel.GoToDislikesCommand.ExecuteIfCan());
            var interests = split.AddButton("Interests", "-", () => ViewModel.GoToInterestsCommand.ExecuteIfCan());

            ViewModel.WhenAnyValue(x => x.Likes).Subscribe(x => likes.Text         = x.ToString());
            ViewModel.WhenAnyValue(x => x.Dislikes).Subscribe(x => dislikes.Text   = x.ToString());
            ViewModel.WhenAnyValue(x => x.Interests).Subscribe(x => interests.Text = x.ToString());

            var section = new Section {
                HeaderView = HeaderView
            };

            section.Add(split);

            var section2 = new Section();

            ViewModel.StumbleHistory.Changed.Subscribe(_ =>
            {
                section2.Reset(ViewModel.StumbleHistory.Select(x =>
                                                               new RepositoryElement(x.Owner, x.Name, x.Description, x.ImageUrl,
                                                                                     () => ViewModel.GoToRepositoryCommand.ExecuteIfCan(x))));
            });

            var section3 = new Section();

            ViewModel.WhenAnyValue(x => x.HasMoreHistory).Subscribe(x =>
            {
                if (x)
                {
                    section3.Reset(new [] {
                        new StyledStringElement("See More History", () => ViewModel.GoToHistoryCommand.ExecuteIfCan())
                    });
                }
                else
                {
                    section3.Clear();
                }
            });


            Root.Reset(section, section2, section3);
        }
Example #24
0
 public void Clear()
 {
     Section?.Clear();
 }