Exemplo n.º 1
0
        void AddSource(string link)
        {
            try
            {
                var uri = new Uri(link).ToString();
                if (uri[uri.Length - 1] != '/')
                {
                    uri = uri + '/';
                }

                foreach (var src in Sources)
                {
                    if (uri == src.ToString())
                    {
                        MessageBox.Show("The given URI is already exist.", "Can't add source",
                                        MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                }

                var sd = new SourceDefinition(uri);
                Sources.Add(sd);
                sd.ApplySources(Sources);
                wapkg.PushSources(Sources);
            }

            catch (UriFormatException)
            {
                MessageBox.Show("Invalid URI.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }