windows eventlog: implement clicking on files/dirs to open them

This commit is contained in:
Hylke Bons 2012-03-10 20:24:01 +00:00
parent 1568067c04
commit 03639bbb01
4 changed files with 40 additions and 27 deletions

View file

@ -1203,7 +1203,7 @@ namespace SparkleShare {
if (string.IsNullOrEmpty (crumb))
continue;
string crumb_path = Path.Combine (new_path_root, crumb);
if (Directory.Exists (crumb_path)) {

View file

@ -161,7 +161,7 @@ namespace SparkleShare {
if (UpdateContentEvent != null)
UpdateContentEvent (HTML);
};
Program.Controller.OnIdle += delegate {
if (UpdateContentEvent != null)
UpdateContentEvent (HTML);
@ -198,7 +198,9 @@ namespace SparkleShare {
public void LinkClicked (string url)
{
if (url.StartsWith (Path.VolumeSeparatorChar.ToString ())) {
if (url.StartsWith (Path.VolumeSeparatorChar.ToString ()) ||
url.Substring (1, 1).Equals (":")) {
Program.Controller.OpenFile (url);
} else {

View file

@ -18,13 +18,13 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Navigation;
namespace SparkleShare {
@ -89,9 +89,12 @@ namespace SparkleShare {
this.web_browser = new WebBrowser () {
Width = Width - 7,
Height = Height - 36 - 12
Height = Height - 36 - 12,
};
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();;
// Disable annoying IE clicking sound
CoInternetSetFeatureEnabled (21, 0x00000002, true);
@ -100,7 +103,7 @@ namespace SparkleShare {
Content = this.canvas;
this.canvas.Children.Add (size_label);
Canvas.SetLeft (size_label, 22);
Canvas.SetLeft (size_label, 24);
Canvas.SetTop (size_label, 4);
this.canvas.Children.Add (this.size_label_value);
@ -211,7 +214,7 @@ namespace SparkleShare {
};
this.canvas.Children.Add (combo_box);
Canvas.SetLeft (this.combo_box, Width - 18 - this.combo_box.Width);
Canvas.SetLeft (this.combo_box, Width - 24 - this.combo_box.Width);
Canvas.SetTop (this.combo_box, 6);
}
@ -221,6 +224,9 @@ namespace SparkleShare {
Thread thread = new Thread (new ThreadStart (delegate {
if (html == null)
html = Controller.HTML;
html = html.Replace ("<a href=", "<a class='windows' href=");
html = html.Replace ("<!-- $body-font-family -->", "sans-serif");
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13.6px");
@ -249,21 +255,13 @@ namespace SparkleShare {
//html = html.Replace ("<!-- $document-moved-background-image -->",
// "file://" + Path.Combine (NSBundle.MainBundle.ResourcePath,
//"Pixmaps", "document-moved-12.png"));
Dispatcher.Invoke ((Action) delegate {
//if (this.progress_indicator.Superview == ContentView) TODO: spinner
// this.progress_indicator.RemoveFromSuperview ();
this.web_browser.LoadCompleted += delegate(object sender, NavigationEventArgs e) {
this.web_browser.Navigating += delegate(object sender2, NavigatingCancelEventArgs e2) {
MessageBox.Show (e2.Uri.ToString ());
e2.Cancel = true;
};
};
this.web_browser.NavigateToString (html);
//MessageBox.Show (html);
if (!this.canvas.Children.Contains (this.web_browser)) {
this.canvas.Children.Add (this.web_browser);
Canvas.SetLeft (this.web_browser, 0);
@ -286,7 +284,18 @@ namespace SparkleShare {
[DllImport ("urlmon.dll")]
[PreserveSig]
[return:MarshalAs (UnmanagedType.Error)]
static extern int CoInternetSetFeatureEnabled (int feature,
[MarshalAs (UnmanagedType.U4)] int flags, bool enable);
static extern int CoInternetSetFeatureEnabled (
int feature, [MarshalAs (UnmanagedType.U4)] int flags, bool enable);
}
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[ComVisible(true)]
public class SparkleScriptingObject {
public void LinkClicked (string url)
{
SparkleUI.EventLog.Controller.LinkClicked (url);
}
}
}

View file

@ -9,8 +9,12 @@
<script type="text/javascript">
$(document).ready(function () {
$('dl dd:nth-child(-n+10)').css('display', 'block');
$('.day-entry-content .event-entry:last-child').css('border', 'none');
$('dd a.windows').click(function () {
window.external.LinkClicked($(this).attr("href"));
});
// Update the Today and Yesterday labels after midnight
var midnight_interval = setInterval (function(){
@ -130,14 +134,11 @@
margin-bottom: 36px;
font-weight: bold;
}
.day-entry-content .event-entry:last-child {
border: none;
}
a {
color: <!-- $a-color -->;
text-decoration: none;
outline: 0;
}
a:hover {
@ -179,7 +180,7 @@
border-radius: 5px;
font-family: sans-serif;
font-size: 12px;
float:right;
float: right;
}
@ -187,11 +188,11 @@
margin-bottom: 24px;
padding-bottom: 24px;
border-bottom: 1px #ddd solid;
width: 99%;
width: 100%;
margin-left: auto;
margin-right: auto;
padding-left: 72px;
padding-right: 12px;
padding-right: 24px;
background-repeat: no-repeat;
background-position: 12px top;
display: block;
@ -231,6 +232,7 @@
margin-bottom: 12px;
padding-top: 6px;
clear: both;
table-layout: fixed;
}
dd {