예제 #1
0
        protected void OnCellDoubleClick(object sender, EventArgs e)
        {
            JournalViewListItem selectedItem = _grid.SelectedItem as JournalViewListItem;

            if (selectedItem == null)
            {
                return;
            }

            MainWindow.Navigate <FileView>((window, view) =>
            {
                view.FilePath = selectedItem.FilePath;
            });
        }
예제 #2
0
        private void LoadBindings(IEnumerable <BindingSet> bindings)
        {
            Dictionary <string, JournalViewListItem> items = new Dictionary <string, JournalViewListItem>();

            foreach (BindingSet binding in bindings)
            {
                string url = binding["fileUrl"].ToString();

                // Skip any malformed URIs.
                if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
                {
                    continue;
                }

                // Do not list files which do not exist.
                string path = new Uri(url).LocalPath;

                if (!File.Exists(path))
                {
                    continue;
                }

                UriRef   agent       = new UriRef(binding["agent"].ToString());
                DateTime startTime   = (DateTime)binding["startTime"];
                DateTime endTime     = (DateTime)binding["endTime"];
                TimeSpan editingTime = endTime - startTime;

                JournalViewListItem item = new JournalViewListItem()
                {
                    Agent            = agent,
                    FileUrl          = url,
                    FilePath         = path,
                    LastEditingDate  = startTime,
                    TotalEditingTime = editingTime
                };

                if (items.ContainsKey(path))
                {
                    items[path].TotalEditingTime += item.TotalEditingTime;
                }
                else
                {
                    items[path] = item;
                }
            }

            _grid.DataStore = items.Values;
        }
예제 #3
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            if (e.Key == Keys.Enter)
            {
                JournalViewListItem selectedItem = _grid.SelectedItem as JournalViewListItem;

                if (selectedItem == null)
                {
                    return;
                }

                string filePath = selectedItem.FilePath;

                if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
                {
                    return;
                }

                RaiseFileSelected(new FileSelectionEventArgs(filePath));
            }
            else if (e.Key == Keys.Space)
            {
                JournalViewListItem selectedItem = _grid.SelectedItem as JournalViewListItem;

                if (selectedItem == null)
                {
                    return;
                }

                RaiseFileSelected(new FileSelectionEventArgs(selectedItem.FilePath));
            }
            else if (e.Key == Keys.F5)
            {
                Refresh();
            }
        }