Skip to content

Commit

Permalink
statusbar info about sync results
Browse files Browse the repository at this point in the history
  • Loading branch information
sepich committed Feb 21, 2015
1 parent 32dbded commit fe78239
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 34 deletions.
25 changes: 12 additions & 13 deletions SynNotes/Form.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions SynNotes/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ private void Form1_Shown(object sender, EventArgs e) {
var ui = TaskScheduler.FromCurrentSynchronizationContext();
//delay inits after form drawn
Task.Factory.StartNew(() => {


// send mouse wheel event to control under cursor
Application.AddMessageFilter(new MouseWheelMessageFilter());

// read sync acc
using (SQLiteCommand cmd = new SQLiteCommand("SELECT value FROM config WHERE name='email'", sql)) {
var res = cmd.ExecuteScalar();
Expand All @@ -111,7 +106,9 @@ private void Form1_Shown(object sender, EventArgs e) {
SnSync(0, ui);// start full sync on start
}
}).ContinueWith(t => {
// update gui
// send mouse wheel event to control under cursor
Application.AddMessageFilter(new MouseWheelMessageFilter());

// hotkeys
hook = new KeyHook();
hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(HotkeyPressed);
Expand Down Expand Up @@ -588,8 +585,6 @@ private static int[] GetIntArrayFromByteArray(byte[] byteArray) {
private void tree_SelectionChanged(object sender, EventArgs e) {
if (scEdit.Modified) note.Save();
note.ShowSelected();
saveTimer.Stop(); //dont autosave on textchange this time
statusText.Text = Glob.Saved;
}

// expand tag by key / mouse click
Expand Down Expand Up @@ -1002,10 +997,12 @@ private void tree_ModelDropped(object sender, ModelDropEventArgs e) {
break;
case DropTargetLocation.Item:
moveNote(e.SourceModels, (TagItem)e.TargetModel, e.StandardDropActionFromKeys);
e.RefreshObjects();
cName.Renderer = fancyRenderer; //OLV drop renderer when Roots assigned
e.RefreshObjects();
break;
}
//OLV drops renderer/sort when Roots assigned
cName.Renderer = fancyRenderer;
tree.Sort(cSort, SortOrder.Ascending);
}

//note change/add tag
Expand Down Expand Up @@ -1066,8 +1063,6 @@ private void moveTag(IList from, TagItem to, int offset = 0) {
if (!x.System) x.Index = i++;
});
tree.Roots = tags;
cName.Renderer = fancyRenderer; //OLV drop renderer when Roots assigned
tree.Sort();
tree.SelectedObjects = from;
//save to db
using (SQLiteTransaction tr = sql.BeginTransaction()) {
Expand All @@ -1084,7 +1079,7 @@ private void moveTag(IList from, TagItem to, int offset = 0) {
}
}
tr.Commit();
}
}
}
#endregion tree drag'n'drop

Expand Down Expand Up @@ -1440,7 +1435,7 @@ private void timer_sync(object sender, EventArgs e) {
/// </summary>
private void SnSync(double since, TaskScheduler ui=null) {
if(ui == null) ui = TaskScheduler.FromCurrentSynchronizationContext();
statusText.Text = "syncing...";
statusText.Text = "Syncing...";
// detach from ui thread
Task.Factory.StartNew<string>(() => {

Expand Down Expand Up @@ -1506,7 +1501,9 @@ private void SnSync(double since, TaskScheduler ui=null) {
});
}

return (num == 0) ? Sync.Email : num + " new";
var dt = Glob.Epoch.AddSeconds(Sync.LastSync).ToLocalTime();
var stat = (num > 0) ? " (" + num + " items)" : "";
return String.Format("Last Sync: {0}{1}", dt.ToString("HH:mm"), stat);

}
catch (AggregateException e) {
Expand Down
2 changes: 1 addition & 1 deletion SynNotes/Form.resx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACM
CwAAAk1TRnQBSQFMAgEBCgEAARgBAQEYAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CwAAAk1TRnQBSQFMAgEBCgEAASABAQEgAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down
10 changes: 6 additions & 4 deletions SynNotes/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public partial class Form1 : Form {
class Note {
private Form1 f; // main form
public NoteItem Item { get; set; } // currently opened note
private int syncnum; // ver of opened note for auto update
private List<Label> Labels; // tag labels displayed
private int syncnum; // ver of opened note for auto update

public Note(Form1 form) {
Labels = new List<Label>();
Expand All @@ -36,12 +36,13 @@ public void ShowSelected() {
syncnum = n.SyncNum;
}
else return; // don't redraw same note (in search mode)
f.scEdit.DocumentChange -= f.scEdit_DocumentChange;

using (SQLiteCommand cmd = new SQLiteCommand(f.sql)) {
cmd.CommandText = "SELECT content, lexer, topline FROM notes WHERE id=" + Item.Id;
using (SQLiteDataReader rdr = cmd.ExecuteReader()) {
while (rdr.Read()) {
f.scEdit.Text = rdr.GetString(0);
while (rdr.Read()) {
f.scEdit.Text = rdr.GetString(0);
if (rdr.IsDBNull(1)) { //use tag's lexer
var lex = "Bash";
foreach (var tag in Item.Tags) if (!String.IsNullOrEmpty(tag.Lexer)) {
Expand All @@ -63,8 +64,9 @@ public void ShowSelected() {
}
}
f.scEdit.Modified = false;
f.scEdit.DocumentChange += f.scEdit_DocumentChange;
f.Text = GetTitle();
drawTags();
drawTags();
//highlight search term and scroll to it
if (f.tbSearch.ForeColor == SystemColors.WindowText && f.tbSearch.Text.Length > 0) {
var top = f.scEdit.Lines.Count;
Expand Down
2 changes: 1 addition & 1 deletion SynNotes/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("15.02.19.0")]
[assembly: AssemblyFileVersion("15.02.21.0")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]

0 comments on commit fe78239

Please sign in to comment.