Пример #1
0
        public void My_Load()
        {
            svn.Authentication.UserNamePasswordHandlers += new EventHandler <SharpSvn.Security.SvnUserNamePasswordEventArgs>(
                delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
            {
                e1.UserName = GlobalVariable.svnUserName;
                e1.Password = GlobalVariable.svnPassword;
            });
            dir = redis.Get <string>(RedisKeyName.svnBaseDirKey);
            SvnTarget repos = (SvnTarget)dir;
            Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();

            try
            {
                if (svn.GetList(repos, out list))
                {
                    list.RemoveAt(0);
                    foreach (var file in list)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header = file.Name;
                        item.Tag    = dir + file.Name;
                        item.Items.Add(_dummyNode);
                        item.Expanded += folder_Expanded;
                        TreeViewItemProps.SetFileType(item, "folder");
                        folderTree.Items.Add(item);
                    }
                }
            }
            catch (SvnException ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Warning);
                this.Close();
            }
        }
Пример #2
0
        private void folder_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = (TreeViewItem)sender;

            if (item.Items.Count == 1 && item.Items[0] == _dummyNode)
            {
                item.Items.Clear();
                try
                {
                    Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();
                    string    sub_dir = (string)item.Tag;
                    SvnTarget repos   = (SvnTarget)sub_dir;
                    svn.GetList(repos, out list);
                    if (list.Count > 1 && !TreeViewItemProps.GetFileType(item).Equals("folder"))
                    {
                        TreeViewItemProps.SetFileType(item, "folder");
                    }
                    list.RemoveAt(0);
                    foreach (var file in list)
                    {
                        TreeViewItem sub_item = new TreeViewItem();
                        if (file.Name.Contains(".txt"))
                        {
                            TreeViewItemProps.SetFileType(sub_item, "txt");
                        }
                        else if (file.Name.Contains(".exe"))
                        {
                            TreeViewItemProps.SetFileType(sub_item, "exe");
                        }
                        else
                        {
                            if (file.Name.Contains(".c") ||
                                file.Name.Contains(".py") ||
                                file.Name.Contains(".sh") ||
                                file.Name.Contains(".h") ||
                                file.Name.Contains(".lua") ||
                                file.Name.Contains(".js"))
                            {
                                TreeViewItemProps.SetFileType(sub_item, "code");
                            }
                            else if (file.Name.Contains("."))
                            {
                                TreeViewItemProps.SetFileType(sub_item, "unknown");
                            }
                        }
                        sub_item.Header = file.Name;
                        sub_item.Tag    = sub_dir + "/" + file.Name;
                        sub_item.Items.Add(_dummyNode);
                        sub_item.Expanded += folder_Expanded;
                        item.Items.Add(sub_item);
                    }
                }
                catch (Exception) { }
            }
        }