Exemple #1
0
        private void azuki_DragDrop(object sender, DragEventArgs e)
        {
            var paths     = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            var count     = lvModifiableFile.Items.Count;
            var filePaths = paths.SelectMany(
                path =>
                Directory.Exists(path)
                                    ? Directory.EnumerateFiles(
                    path, "*", SearchOption.AllDirectories)
                .Where(
                    filePath =>
                    _activeProcessor.SupportedExtensions
                    .Contains(
                        Path.GetExtension(
                            filePath)))
                                    : Enumerable.Repeat(path, 1));

            foreach (var filePath in filePaths)
            {
                var file     = new FileInfo(filePath);
                var codeFile = new CodeFile(_activeProcessor, file);
                var item     = new FileListViewItem(codeFile);
                lvModifiableFile.Items.Add(item);
            }
            lvModifiableFile.Items[count].Selected = true;
        }
 public UpdateFilesCommand(JsonObject response)
 {
     Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Program.Settings.Locale, true);
     Program.DaemonDescriptor.ResetFailCount();
     MainWindow form = Program.Form;
     JsonObject arguments = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS];
     JsonArray torrents = (JsonArray)arguments[ProtocolConstants.KEY_TORRENTS];
     if (torrents.Count != 1)
     {
         return;
     }
     JsonObject torrent = (JsonObject)torrents[0];
     JsonArray files = (JsonArray)torrent[ProtocolConstants.FIELD_FILES];
     if (files == null)
     {
         return;
     }
     int id = Toolbox.ToInt(torrent[ProtocolConstants.FIELD_ID]);
     Torrent t = (Torrent)form.Invoke(new GetTorrentDelegate(delegate()
     {
         lock (Program.TorrentIndex)
         {
             foreach (KeyValuePair<string, Torrent> st in Program.TorrentIndex)
             {
                 if (st.Value.Id == id)
                     return st.Value;
             }
         }
         return null;
     }));
     if (t == null)
     {
         return;
     }
     JsonArray priorities = (JsonArray)torrent[ProtocolConstants.FIELD_PRIORITIES];
     JsonArray wanted = (JsonArray)torrent[ProtocolConstants.FIELD_WANTED];
     bool havepriority = (priorities != null && wanted != null);
     ImageList imgList = Program.Form.fileIconImageList;
     for (int i = 0; i < files.Length; i++)
     {
         JsonObject file = (JsonObject)files[i];
         string name = Toolbox.TrimPath((string)file[ProtocolConstants.FIELD_NAME]);
         FileListViewItem item = t.Files.Find(name);
         if (item == null)
         {
             item = new FileListViewItem(file, imgList, i, wanted, priorities);
             t.Files.Add(item);
         }
         else
         {
             Program.Form.Invoke(new MethodInvoker(delegate()
             {
                 item.Update(file, wanted, priorities);
             }));
         }
     }
 }
Exemple #3
0
        private void InteractiveResolveRB_CheckedChanged(object sender, EventArgs e)
        {
            FileListViewItem selection = null;

            if ((FileList.SelectedItems != null) && (FileList.SelectedItems.Count > 0))
            {
                selection = (FileListViewItem)FileList.SelectedItems[0];
                if (selection.FirstItem != null)
                {
                    selection = selection.FirstItem;
                }
            }
            else
            {
                return;
            }
            if (selection.ResolveType == P4.ResolveType.Content)
            {
                //CurrentView = ViewType.Interactive;

                resolveFileAutoControl1.Visible        = false;
                resolveFileInteractiveControl1.Visible = true;
                resolveFileActionControl1.Visible      = false;
            }
            else
            {
                //CurrentView = ViewType.Action;

                resolveFileAutoControl1.Visible        = false;
                resolveFileInteractiveControl1.Visible = false;
                resolveFileActionControl1.Visible      = true;
            }

            //FileListViewItem sel = (FileListViewItem)FileList.Items[0];
            //if ((FileList.SelectedItems!= null) && (FileList.SelectedItems.Count > 0))
            //{
            //    sel = (FileListViewItem) FileList.SelectedItems[0];
            //}
            FileList.MultiSelect = false;
            FileList.SelectedItems.Clear();
            //if (sel != null)
            //{
            //    sel.Selected = true;
            //}
            //bool bFirst = true;
            foreach (FileListViewItem item in FileList.Items)
            {
                item.Selected = false;                 //bFirst;
                //bFirst = false;
            }
            selection.Selected = true;
        }
 private void OnFileDeteledFinishEventHandler(RemoteFileAdapterHandler adapterHandler, string[] deletedFiles)
 {
     for (int i = 0; i < fileList.Items.Count; i++)
     {
         FileListViewItem item = fileList.Items[i] as FileListViewItem;
         foreach (var file in deletedFiles)
         {
             if (item.FileName == Path.GetFileName(file))
             {
                 item.Remove();
                 i--;
             }
         }
     }
 }
 private void OnFileNameRenameFinishEventHandler(RemoteFileAdapterHandler adapterHandler, string srcNamec, string targetName, bool isSuccess)
 {
     if (isSuccess)
     {
         for (int i = 0; i < fileList.Items.Count; i++)
         {
             FileListViewItem item = fileList.Items[i] as FileListViewItem;
             if (item.FileName == Path.GetFileName(srcNamec))
             {
                 item.Text     = Path.GetFileName(targetName);
                 item.FileName = Path.GetFileName(targetName);
                 break;
             }
         }
     }
     else
     {
         MessageBoxHelper.ShowBoxError("文件重命名失败!");
     }
 }
Exemple #6
0
        public void OnFolderTreeSelect(object sender, TreeViewEventArgs e)
        {
            FolderTreeNode folderNode = (FolderTreeNode)e.Node;

            fsFolderInfoFullName.Text = "";
            fsFolderInfoIsolationCombo.SelectedIndex = -1;
            if (folderNode == null)
            {
                return;
            }
            fsFolderInfoIsolationCombo.Enabled = true;     //(folderNode != fsFolderTree.Nodes[0]);
            VirtFsNode virtFsNode = folderNode.virtFsNode; // Avoids CS1690

            // Fill info panel
            String fullName = treeHelper.GetFullNodeName(folderNode);

            fsFolderInfoFullName.Text = "[" + Win32Function.StrFormatByteSize64(virtFsNode.EndOfFile) + "] " + fullName;
            fsFolderInfoIsolationCombo.SelectedIndex = treeHelper.SandboxFlagsToComboIndex(
                virtPackage.GetFileSandbox(fullName, false));

            // Fill fsFilesList
            fsFilesList.Items.Clear();
            if (folderNode.childFiles != null)
            {
                for (int i = folderNode.childFiles.Count - 1; i >= 0; i--)
                {
                    FileData         childFile = folderNode.childFiles[i];
                    FileListViewItem newItem   = new FileListViewItem();
                    newItem.Text = Path.GetFileName(childFile.virtFsNode.FileName);
                    newItem.SubItems.Add(Win32Function.StrFormatByteSize64(childFile.virtFsNode.EndOfFile));

                    newItem.flags = (VIRT_FILE_FLAGS)childFile.virtFsNode.FileFlags;

                    if ((newItem.flags & VirtPackageAPI.VIRT_FILE_FLAGS.DEPLOY_UPON_PRELOAD) != 0)
                    {
                        newItem.ImageIndex = 7;
                    }
                    else
                    {
                        newItem.ImageIndex = 6;
                    }
                    //ListViewItem.ListViewSubItem x = new ListViewItem.ListViewSubItem();
                    //x.Text = ((VIRT_FILE_FLAGS)childFile.virtFsNode.FileFlags).ToString();
                    //newItem.SubItems.Add(x);
                    newItem.SubItems.Add(Path.GetExtension(newItem.Text));

                    newItem.fileSize = childFile.virtFsNode.EndOfFile;
                    if (childFile.addedFrom != "")
                    {
                        if (folderNode.deleted)
                        {
                            folderNode.childFiles.Remove(childFile);       // Added file in a Removed folder. Forbidden!!
                            continue;
                        }
                        else
                        {
                            newItem.ForeColor = Color.Green;               // Newly-added
                        }
                    }
                    else if (folderNode.ImageIndex == 5)                   // deleted
                    {
                        newItem.ForeColor = Color.Red;
                    }
                    else if (childFile.deleted)
                    {
                        newItem.ForeColor = Color.Red;
                    }
                    fsFilesList.Items.Add(newItem);
                }
            }
        }
		private void azuki_DragDrop(object sender, DragEventArgs e) {
			var paths = (string[])e.Data.GetData(DataFormats.FileDrop, false);
			var count = lvModifiableFile.Items.Count;
			var filePaths = paths.SelectMany(path =>
					Directory.Exists(path)
							? Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)
									.Where(filePath => _activeCodeToXml.TargetExtensions.Contains(Path.GetExtension(filePath)))
							: Enumerable.Repeat(path, 1));
			foreach (var filePath in filePaths) {
				var file = new FileInfo(filePath);
				var codeFile = new CodeFile(_activeCodeToXml, file);
				var item = new FileListViewItem(codeFile);
				lvModifiableFile.Items.Add(item);
			}
			lvModifiableFile.Items[count].Selected = true;
		}
Exemple #8
0
        public UpdateFilesCommand(JsonObject response)
        {
            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Program.Settings.Locale, true);
            Program.DaemonDescriptor.ResetFailCount();
            MainWindow form      = Program.Form;
            JsonObject arguments = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS];
            JsonArray  torrents  = (JsonArray)arguments[ProtocolConstants.KEY_TORRENTS];

            if (torrents.Count != 1)
            {
                return;
            }

            JsonObject torrent = (JsonObject)torrents[0];
            JsonArray  files   = (JsonArray)torrent[ProtocolConstants.FIELD_FILES];

            if (files == null)
            {
                return;
            }

            int id = Toolbox.ToInt(torrent[ProtocolConstants.FIELD_ID]);
            var t  = (Torrent)form.Invoke(new GetTorrentDelegate(delegate
            {
                lock (Program.TorrentIndex)
                {
                    foreach (KeyValuePair <string, Torrent> st in Program.TorrentIndex)
                    {
                        if (st.Value.Id == id)
                        {
                            return(st.Value);
                        }
                    }
                }
                return(null);
            }));

            if (t == null)
            {
                return;
            }
            JsonArray priorities   = (JsonArray)torrent[ProtocolConstants.FIELD_PRIORITIES];
            JsonArray wanted       = (JsonArray)torrent[ProtocolConstants.FIELD_WANTED];
            bool      havepriority = priorities != null && wanted != null;
            ImageList imgList      = Program.Form.fileIconImageList;

            for (int i = 0; i < files.Length; i++)
            {
                JsonObject       file = (JsonObject)files[i];
                string           name = Toolbox.TrimPath((string)file[ProtocolConstants.FIELD_NAME]);
                FileListViewItem item = t.Files.Find(name);
                if (item == null)
                {
                    item = new FileListViewItem(file, imgList, i, wanted, priorities);
                    t.Files.Add(item);
                }
                else
                {
                    Program.Form.Invoke(new MethodInvoker(delegate
                    {
                        item.Update(file, wanted, priorities);
                    }));
                }
            }
        }
Exemple #9
0
        private void FileList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SelectionCountLblTxt != null)
            {
                SelectionCountLbl.Text = string.Format(SelectionCountLblTxt,
                                                       (FileList.SelectedItems != null) ? FileList.SelectedItems.Count : 0,
                                                       (FileList.Items != null) ? FileList.Items.Count : 0);
            }

            //foreach (FileListViewItem sel in FileList.SelectedItems)
            //{
            //    if ((sel.FirstItem != null) && (sel.FirstItem.Selected == false))
            //    {
            //        sel.Selected = false;
            //        return;
            //    }
            //}
            FileListViewItem selection = null;

            if ((FileList.SelectedItems != null) && (FileList.SelectedItems.Count > 0))
            {
                selection = (FileListViewItem)FileList.SelectedItems[0];
                //if ((FileList.MultiSelect == false) && (selection.FirstItem != null))
                //{
                //    selection.Selected = false;
                //    return;
                //}
                resolveFileInteractiveControl1.SelectedItem = selection;
                resolveFileActionControl1.SelectedItem      = selection;
            }
            else
            {
                resolveFileInteractiveControl1.SelectedItem = null;
                resolveFileActionControl1.SelectedItem      = null;
            }
            List <FileListViewItem> SelectedItems = null;

            if ((FileList.SelectedItems != null) && (FileList.SelectedItems.Count > 0))
            {
                SelectedItems = new List <FileListViewItem>();
                foreach (ListViewItem item in FileList.SelectedItems)
                {
                    SelectedItems.Add(item as FileListViewItem);
                }
            }
            resolveFileAutoControl1.SelectedItems = SelectedItems;
            if ((InteractiveResolveRB.Checked) && (selection != null))
            {
                if (selection.ResolveType == P4.ResolveType.Content)
                {
                    //CurrentView = ViewType.Interactive;

                    resolveFileAutoControl1.Visible        = false;
                    resolveFileInteractiveControl1.Visible = true;
                    resolveFileActionControl1.Visible      = false;
                }
                else
                {
                    //CurrentView = ViewType.Action;

                    resolveFileAutoControl1.Visible        = false;
                    resolveFileInteractiveControl1.Visible = false;
                    resolveFileActionControl1.Visible      = true;
                }
            }
        }
Exemple #10
0
        private void InitFileListView()
                #region single pass initialization of the list
        {
            this.FileList.Items.Clear();
//			itemMap = null;

            if (_files == null)
            {
                return;
            }
//			itemMap = new Dictionary<string, FileListViewItem>();
            resolveCallback = new P4.Client.ResolveFileDelegate(ResolveCallBackHandler);

            P4.Options options = new P4.ResolveCmdOptions(
                P4.ResolveFilesCmdFlags.ForceTextualMerge | P4.ResolveFilesCmdFlags.DisplayBaseFile, -1);

            int itemCnt = 0;

            IList <P4.P4Exception> errors = null;

            IList <string> filesNotListed = new List <string>();

            foreach (string file in _files)
            {
                IList <P4.FileResolveRecord> records = null;
                try
                {
                    records = _scm.Connection.Repository.Connection.Client.ResolveFiles(
                        resolveCallback, options, P4.FileSpec.LocalSpec(file));
                }
                catch (P4.P4Exception ex)
                {
                    if (errors == null)
                    {
                        errors = new List <P4.P4Exception>();
                    }
                    errors.Add(ex);
                }
                P4.P4CommandResult results = _scm.Connection.Repository.Connection.LastResults;

                int subItemIdx = 0;

                FileListViewItem firstItem = null;

                if ((records != null) && (records.Count > 0))
                {
                    foreach (P4.FileResolveRecord record in records)
                    {
                        string path = null;
                        if (record.LocalFilePath != null)
                        {
                            path = record.LocalFilePath.Path;
                        }
                        else if ((record.FromFileSpec != null) && (record.FromFileSpec.LocalPath != null))
                        {
                            path = record.FromFileSpec.LocalPath.Path;
                        }
                        else
                        {
                            continue;
                        }

                        CurrentItem = new FileListViewItem(path, subItemIdx);

                        if (subItemIdx == 0)
                        {
                            firstItem = CurrentItem;
                        }
                        else
                        {
                            CurrentItem.FirstItem = firstItem;
                        }
                        subItemIdx++;

                        // string key = string.Format("<{0}>{1}", record.ResolveType, path.ToLower());
                        //				itemMap.Add(key, CurrentItem);

                        this.FileList.Items.Add(CurrentItem);

                        CurrentItem.ResolveRecord = record;
                        CurrentItem.Source        = record.FromFileSpec;
                        if (record.ResolveType != P4.ResolveType.None)
                        {
                            CurrentItem.ResolveType = record.ResolveType;
                        }
                        else if ((record.Analysis != null) && (record.Analysis.ResolveType != P4.ResolveType.None))
                        {
                            CurrentItem.ResolveType = record.Analysis.ResolveType;
                        }
                        CurrentItem.ResolveAnalysis = record.Analysis;


                        CurrentItem = null;
                    }
                }
                else
                {
                    filesNotListed.Add(file);
                }
            }
            if (errors != null)
            {
                P4ErrorDlg.Show(errors, false);
            }
            // clean out files that do not need to be resolved
            foreach (string file in filesNotListed)
            {
                _files.Remove(file);
            }

            if (RefreshUICallback != null)
            {
                RefreshUICallback();
            }
            if ((_files == null) || (_files.Count <= 0))
            {
                // no files to resolve
                if (bFirstInit)
                {
                    MessageBox.Show(Resources.ResolveFileDlg_NoFileToResolveWarning, Resources.P4VS,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    this.DialogResult = DialogResult.OK;
                    Close();
                    return;
                }
            }
            bFirstInit = false;

            SelectionCountLbl.Text = string.Format(SelectionCountLblTxt, 0, itemCnt);

            resolveCallback = null;

            AutoResolveRB_CheckedChanged(null, null);
        }