From fe782396af30f2e31e966cd9de2259848f6c5cd6 Mon Sep 17 00:00:00 2001 From: sepa Date: Sat, 21 Feb 2015 17:22:33 +0300 Subject: [PATCH] statusbar info about sync results --- SynNotes/Form.Designer.cs | 25 ++++++++++++------------- SynNotes/Form.cs | 27 ++++++++++++--------------- SynNotes/Form.resx | 2 +- SynNotes/Note.cs | 10 ++++++---- SynNotes/Properties/AssemblyInfo.cs | 2 +- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/SynNotes/Form.Designer.cs b/SynNotes/Form.Designer.cs index b8cb7a1..d2d7a0e 100644 --- a/SynNotes/Form.Designer.cs +++ b/SynNotes/Form.Designer.cs @@ -38,6 +38,8 @@ private void InitializeComponent() this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.tree = new BrightIdeasSoftware.TreeListView(); + this.cName = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); + this.fancyRenderer = new SynNotes.FancyRenderer(); this.cSort = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); this.treeMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.imageList1 = new System.Windows.Forms.ImageList(this.components); @@ -53,8 +55,6 @@ private void InitializeComponent() this.scEdit = new ScintillaNET.Scintilla(); this.lexerMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); - this.cName = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); - this.fancyRenderer = new SynNotes.FancyRenderer(); trayMenu = new System.Windows.Forms.ContextMenuStrip(this.components); trayMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -191,6 +191,15 @@ private void InitializeComponent() this.tree.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.tree_ItemDrag); this.tree.MouseClick += new System.Windows.Forms.MouseEventHandler(this.tree_MouseClick); // + // cName + // + this.cName.AspectName = "Name"; + this.cName.AutoCompleteEditor = false; + this.cName.AutoCompleteEditorMode = System.Windows.Forms.AutoCompleteMode.None; + this.cName.FillsFreeSpace = true; + this.cName.Renderer = this.fancyRenderer; + this.cName.Text = "Name"; + // // cSort // this.cSort.AspectName = ""; @@ -207,8 +216,7 @@ private void InitializeComponent() // treeMenu // this.treeMenu.Name = "treeMenu"; - this.treeMenu.ShowImageMargin = false; - this.treeMenu.Size = new System.Drawing.Size(36, 4); + this.treeMenu.Size = new System.Drawing.Size(153, 26); // // imageList1 // @@ -423,15 +431,6 @@ private void InitializeComponent() this.notifyIcon1.Visible = true; this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click); // - // cName - // - this.cName.AspectName = "Name"; - this.cName.AutoCompleteEditor = false; - this.cName.AutoCompleteEditorMode = System.Windows.Forms.AutoCompleteMode.None; - this.cName.FillsFreeSpace = true; - this.cName.Renderer = this.fancyRenderer; - this.cName.Text = "Name"; - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/SynNotes/Form.cs b/SynNotes/Form.cs index 447c36d..06760d8 100644 --- a/SynNotes/Form.cs +++ b/SynNotes/Form.cs @@ -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(); @@ -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(HotkeyPressed); @@ -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 @@ -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 @@ -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()) { @@ -1084,7 +1079,7 @@ private void moveTag(IList from, TagItem to, int offset = 0) { } } tr.Commit(); - } + } } #endregion tree drag'n'drop @@ -1440,7 +1435,7 @@ private void timer_sync(object sender, EventArgs e) { /// 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(() => { @@ -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) { diff --git a/SynNotes/Form.resx b/SynNotes/Form.resx index dc4bcff..7e29f72 100644 --- a/SynNotes/Form.resx +++ b/SynNotes/Form.resx @@ -149,7 +149,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACM - CwAAAk1TRnQBSQFMAgEBCgEAARgBAQEYAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CwAAAk1TRnQBSQFMAgEBCgEAASABAQEgAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/SynNotes/Note.cs b/SynNotes/Note.cs index 98f5435..625bac0 100644 --- a/SynNotes/Note.cs +++ b/SynNotes/Note.cs @@ -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