diff --git a/Config.cs b/Config.cs index e83db56..cd21d45 100644 --- a/Config.cs +++ b/Config.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Linq; using System.Runtime.InteropServices; @@ -13,6 +14,11 @@ namespace friction static string m_strPath = ""; static Config() + { + + } + + public static void Init() { string strPrjName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name; string strFolder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), strPrjName); @@ -23,11 +29,6 @@ namespace friction Load(); } - public static void Init() - { - - } - [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); [DllImport("kernel32")] @@ -44,13 +45,43 @@ namespace friction foreach (string strFile in astrList) OPTION.AddRecentFile(strFile); } - + iRes = GetPrivateProfileString("Option", "bound", "", temp, 10240, m_strPath); + if(temp.Length > 0) + { + string[] astrBound = temp.ToString().Split(','); + + int iLeft, iWidth, iTop, iHeight; + + int.TryParse(astrBound[0], out iLeft); + int.TryParse(astrBound[1], out iWidth); + int.TryParse(astrBound[2], out iTop); + int.TryParse(astrBound[3], out iHeight); + + OPTION.WindowBound = new Rectangle(iLeft, iTop, iWidth, iHeight); + } + + iRes = GetPrivateProfileString("Option", "checked-column", "", temp, 10240, m_strPath); + if (temp.Length > 0) + { + string[] astrBound = temp.ToString().Split(','); + OPTION.CheckedColumns = astrBound.ToList(); + } + + iRes = GetPrivateProfileString("Option", "unchecked-column", "", temp, 10240, m_strPath); + if (temp.Length > 0) + { + string[] astrBound = temp.ToString().Split(','); + OPTION.UncheckedColumns = astrBound.ToList(); + } } - private static void Save() + public static void Save() { WritePrivateProfileString("Option", "recent", OPTION.GetRecentAll(), m_strPath); + WritePrivateProfileString("Option", "bound", OPTION.WindowBoundStr(), m_strPath); + WritePrivateProfileString("Option", "checked-column", OPTION.CheckedColumnsStr(), m_strPath); + WritePrivateProfileString("Option", "unchecked-column", OPTION.UncheckedColumnsStr(), m_strPath); } @@ -69,6 +100,9 @@ namespace friction public static class OPTION { public static List m_RecentList = new List(); + public static Rectangle WindowBound { set; get; } + public static List CheckedColumns { set; get; } + public static List UncheckedColumns { set; get; } public static void AddRecentFile(string strPath) { @@ -76,13 +110,50 @@ namespace friction m_RecentList.Remove(strPath); m_RecentList.Add(strPath); - Save(); } public static string GetRecentAll() { return string.Join("//", m_RecentList); } + + public static string WindowBoundStr() + { + return string.Format("{0}, {1}, {2}, {3}", WindowBound.Left, WindowBound.Width, WindowBound.Top, WindowBound.Height); + } + + public static string CheckedColumnsStr() + { + string strResult = ""; + if(CheckedColumns != null) + { + foreach (var item in CheckedColumns) + { + if (strResult.Length > 0) + strResult += ","; + strResult += item; + } + } + + return strResult; + } + + public static string UncheckedColumnsStr() + { + string strResult = ""; + + if(UncheckedColumns != null) + { + foreach (var item in UncheckedColumns) + { + if (strResult.Length > 0) + strResult += ","; + strResult += item; + } + } + + return strResult; + } } diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 0969b94..d0d6e6a 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -36,6 +36,7 @@ this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButtonResult = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonAnalysis = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonMap = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButtonRadarGraph = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonTrendGraph = new System.Windows.Forms.ToolStripButton(); @@ -49,6 +50,7 @@ this.tableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resultTableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.analysisTableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.materialCompatibilityMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.graphToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.radarGraphToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.trendGraphToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -57,8 +59,6 @@ this.aToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dockPanel = new WeifenLuo.WinFormsUI.Docking.DockPanel(); - this.materialCompatibilityMapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripButtonMap = new System.Windows.Forms.ToolStripButton(); this.toolStripMain.SuspendLayout(); this.statusStrip.SuspendLayout(); this.menuStrip.SuspendLayout(); @@ -139,6 +139,17 @@ this.toolStripButtonAnalysis.ToolTipText = "Analysis Table (Ctrl+A)"; this.toolStripButtonAnalysis.Click += new System.EventHandler(this.toolStripButtonAnalysis_Click); // + // toolStripButtonMap + // + this.toolStripButtonMap.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonMap.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonMap.Image"))); + this.toolStripButtonMap.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonMap.Name = "toolStripButtonMap"; + this.toolStripButtonMap.Size = new System.Drawing.Size(23, 22); + this.toolStripButtonMap.Text = "toolStripButton1"; + this.toolStripButtonMap.ToolTipText = "Material Compatibility Map"; + this.toolStripButtonMap.Click += new System.EventHandler(this.toolStripButtonMap_Click); + // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; @@ -251,6 +262,13 @@ this.analysisTableToolStripMenuItem.Text = "Analysis Table"; this.analysisTableToolStripMenuItem.Click += new System.EventHandler(this.analysisTableToolStripMenuItem_Click); // + // materialCompatibilityMapToolStripMenuItem + // + this.materialCompatibilityMapToolStripMenuItem.Name = "materialCompatibilityMapToolStripMenuItem"; + this.materialCompatibilityMapToolStripMenuItem.Size = new System.Drawing.Size(221, 22); + this.materialCompatibilityMapToolStripMenuItem.Text = "Material Compatibility Map"; + this.materialCompatibilityMapToolStripMenuItem.Click += new System.EventHandler(this.materialCompatibilityMapToolStripMenuItem_Click); + // // graphToolStripMenuItem // this.graphToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -286,7 +304,7 @@ // allToolStripMenuItem // this.allToolStripMenuItem.Name = "allToolStripMenuItem"; - this.allToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.allToolStripMenuItem.Size = new System.Drawing.Size(88, 22); this.allToolStripMenuItem.Text = "All"; this.allToolStripMenuItem.Click += new System.EventHandler(this.allToolStripMenuItem_Click); // @@ -314,24 +332,6 @@ this.dockPanel.Size = new System.Drawing.Size(1184, 690); this.dockPanel.TabIndex = 2; // - // materialCompatibilityMapToolStripMenuItem - // - this.materialCompatibilityMapToolStripMenuItem.Name = "materialCompatibilityMapToolStripMenuItem"; - this.materialCompatibilityMapToolStripMenuItem.Size = new System.Drawing.Size(221, 22); - this.materialCompatibilityMapToolStripMenuItem.Text = "Material Compatibility Map"; - this.materialCompatibilityMapToolStripMenuItem.Click += new System.EventHandler(this.materialCompatibilityMapToolStripMenuItem_Click); - // - // toolStripButtonMap - // - this.toolStripButtonMap.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonMap.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonMap.Image"))); - this.toolStripButtonMap.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonMap.Name = "toolStripButtonMap"; - this.toolStripButtonMap.Size = new System.Drawing.Size(23, 22); - this.toolStripButtonMap.Text = "toolStripButton1"; - this.toolStripButtonMap.ToolTipText = "Material Compatibility Map"; - this.toolStripButtonMap.Click += new System.EventHandler(this.toolStripButtonMap_Click); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); @@ -346,6 +346,7 @@ this.MinimumSize = new System.Drawing.Size(800, 600); this.Name = "MainForm"; this.Text = "Material Stick-Slip Analysis"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.toolStripMain.ResumeLayout(false); this.toolStripMain.PerformLayout(); this.statusStrip.ResumeLayout(false); diff --git a/MainForm.cs b/MainForm.cs index 580737b..5d13826 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -44,6 +44,8 @@ namespace friction Config.Init(); UpdateRecentFile(); + if(Config.OPTION.WindowBound.Width > 0) + Bounds = Config.OPTION.WindowBound; } void UpdateRecentFile() @@ -82,6 +84,7 @@ namespace friction m_DBFileName = strFile; } + Cursor.Current = Cursors.WaitCursor; m_DataHandler.LoadData(m_DBFileName); @@ -102,6 +105,8 @@ namespace friction Config.OPTION.AddRecentFile(m_DBFileName); UpdateRecentFile(); + + Cursor.Current = Cursors.Default; } public void OpenPanel(DockContent panel) @@ -171,6 +176,7 @@ namespace friction return; + Cursor.Current = Cursors.WaitCursor; m_Report = new Report(); m_Report.FilePath = strFilePath; @@ -182,6 +188,8 @@ namespace friction m_Report.Export(); + Cursor.Current = Cursors.Default; + //OpenPanel(m_TrendGraphPanel); //m_TrendGraphPanel.CopyChart(PanelTrendGraph.GRAPH_TYPE.HUMIDITY); } @@ -328,5 +336,13 @@ namespace friction OpenPanel(m_ResultPanel); } #endregion + + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) + { + Config.OPTION.WindowBound = this.Bounds; + Config.OPTION.CheckedColumns = m_ResultPanel.GetCheckedColumns(); + Config.OPTION.UncheckedColumns = m_ResultPanel.GetUncheckedColumns(); + Config.Save(); + } } } diff --git a/MainForm.resx b/MainForm.resx index ddb9163..835a14b 100644 --- a/MainForm.resx +++ b/MainForm.resx @@ -161,29 +161,40 @@ 0odP/0+5cRtuwPRbd/9nHT/6f+adu8QZ0HH5yv+SUyfBBoA0Vp87B6an36bYgDvEe2Em0DaQQSDnz7p9 H0xPvXWbsAFVF07/r7xw6n/ZuVP/S8+d/F989sT/ojPH/heeBuIzx/EbMACAgQEAoVdw+F58Mj4AAAAA SU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fHIWAgQEADcT9Wpq2F4AAAAAASUVORK5CYII= + j66o8vyZgKrzx6RBbKwGgELUdeLuv74Tdi0B8TEMuHC6H+hvcIBiNQAE0nccds3YeVQMxCbLAHyKRooB + oBRWeOwYJ4hdf38/ByzaQACfHIWAgQEA/779VU6Qnd0AAAAASUVORK5CYII= @@ -192,17 +203,6 @@ 254, 17 - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAELSURBVDhPYxhcwH/7dgXv3ZsdoFwMAJIDqYFyMYHvzs0N - vru2/IdyMQBIDqQGykUFKYuPvU9cfPhrwsKjv0FsbDhh8eFfyQsPfwOxodoQwHfi7v+kYKg2BGjff+N/ - 274b/1uBuBmIm/Ze/98IxPVAXLfn+v+aPdf+V+++9r8SiqHaEODw26//97z6+H/rs7f/QWwQDeJjEzvw - 9gt2AxovXv4PCqgtLz+D6aKzF7GKgdRCtSEASHD5wxf/W67cAtry5X/n1dv/Z917hlUMpwEzb9//n3vq - FFhxwenT//tv3MMqhtOA9qvX/4fs2w12bhiQLrtwFasYTgNIwVBtCHD49WcHUjBU24ADBgYAaEuMMZze - rScAAAAASUVORK5CYII= - - AAABAAYAEBAAAAAAIABoBAAAZgAAACAgAAAAACAAqBAAAM4EAAAwMAAAAAAgAKglAAB2FQAAQEAAAAAA diff --git a/PanelResult.cs b/PanelResult.cs index 1b2e8cd..b898960 100644 --- a/PanelResult.cs +++ b/PanelResult.cs @@ -47,12 +47,10 @@ namespace friction dgvData.DataSource = data.GetData(); dgvData.DefaultCellStyle.Format = "N2"; - Dictionary CacheChecked = new Dictionary(); - foreach (ListViewItem item in lvColumn.Items) + if(lvColumn.Items.Count > 0) { - string key = item.SubItems[0].Text; - bool bChecked = item.Checked; - CacheChecked.Add(key, bChecked); + Config.OPTION.CheckedColumns = GetCheckedColumns(); + Config.OPTION.UncheckedColumns = GetUncheckedColumns(); } lvColumn.Items.Clear(); @@ -64,8 +62,11 @@ namespace friction { ListViewItem item = new ListViewItem(new string[] { col }); item.Text = col; - if (CacheChecked.ContainsKey(col) == true) - item.Checked = CacheChecked[col]; + + if(Config.OPTION.CheckedColumns != null && Config.OPTION.CheckedColumns.Exists(s => s==col) == true) + item.Checked = true; + else if(Config.OPTION.UncheckedColumns != null && Config.OPTION.UncheckedColumns.Exists(s => s == col) == true) + item.Checked = false; else if (iGroup == 0) item.Checked = true; else @@ -174,5 +175,29 @@ namespace friction dgvData.FirstDisplayedScrollingRowIndex = row.Index; } } + + public List GetCheckedColumns() + { + List result = new List(); + foreach(ListViewItem item in lvColumn.Items) + { + if (item.Checked == true) + result.Add(item.Text); + } + + return result; + } + + public List GetUncheckedColumns() + { + List result = new List(); + foreach (ListViewItem item in lvColumn.Items) + { + if (item.Checked == false) + result.Add(item.Text); + } + + return result; + } } }