diff --git a/Cargo.toml b/Cargo.toml index ed60c08..8292f15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "contrac" description = "ISP connection tracker" -version = "0.6.0" +version = "0.7.0" authors = ["John Shewchuk "] edition = "2018" repository = "https://github.com/johnshew/contrac" @@ -11,7 +11,7 @@ license="MIT" keywords = ["windows", "win32", "network"] [package.metadata.winres] -LegalCopyright = "Copyright © 2020" +LegalCopyright = "Copyright © 2021, 2020" FileDescription = "contrac resources" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/msix/Contrac Local Test.aip b/msix/Contrac Local Test.aip index 7d57c57..e38863e 100644 --- a/msix/Contrac Local Test.aip +++ b/msix/Contrac Local Test.aip @@ -1,5 +1,5 @@ - + @@ -16,6 +16,7 @@ + @@ -35,6 +36,8 @@ + + @@ -74,7 +77,7 @@ - + @@ -100,6 +103,7 @@ + @@ -111,7 +115,7 @@ - + @@ -119,14 +123,18 @@ + + + + - + - + @@ -138,11 +146,11 @@ - + - + @@ -206,6 +214,8 @@ + + @@ -222,6 +232,8 @@ + + diff --git a/msix/Contrac.aip b/msix/Contrac.aip index b12e433..6f53a40 100644 --- a/msix/Contrac.aip +++ b/msix/Contrac.aip @@ -1,5 +1,5 @@ - + @@ -14,6 +14,7 @@ + @@ -33,6 +34,8 @@ + + @@ -90,7 +93,7 @@ - + @@ -109,20 +112,19 @@ - + - - + - + @@ -135,11 +137,11 @@ - + - + @@ -202,6 +204,8 @@ + + @@ -218,6 +222,8 @@ + + diff --git a/notes.md b/notes.md index f25e96f..1d8258b 100644 --- a/notes.md +++ b/notes.md @@ -1,13 +1,42 @@ # Contrac Developer Notes +# Building and deploying -* The graph rendering in Contrac is a hack. Since there are currently no easy-to-use drawing capabilties with native-windows-gui, Contrac uses a collection of small image controls to represent the bars of the graph. +## MSIX and getting it to the Store -* On Windows, by default, Rust starts a console. If you want a Windows app put the following at the top of main.rs. -``` #![windows_subsystem = "windows"] ``` +* Need to create the MSIX first + * Update the version number + * To run locally you might need to create a new cert and set it. + * Remember that the packager takes the release not debug candidate + * Remember to build both x86 and x64 versions + +* Bundle up the files to github and label the release + * Maybe need to set the tag first? + +* Submit to store + * https://partner.microsoft.com/en-us/dashboard/windows/overview + * Remember to update the release notes + +## To build x86 32-bit app +``` +rustup run stable-i686-pc-windows-msvc cargo build --release +``` +In Advanced Application Install go to Package Definitions / Builds and set to x86 + +## Things to watch when building for the store + +# Overall Approach and Learnings +On Windows, by default, Rust starts a console. If you want a Windows app put the following at the top of main.rs. +``` +#![windows_subsystem = "windows"] +``` + +The graph rendering in Contrac is a hack. Since there are currently no easy-to-use drawing capabilties with native-windows-gui, Contrac uses a collection of small image controls to represent the bars of the graph. That said, there maybe now a graphing library. That has the potential to remove a lot of wonky code. + + +## Things that might be useful to PR into native-windows-gui: + * Minimize and restore windows functionality that is working + * Maybe enable WS_CLIPSIBLINGS in flags for controls and enable z-ordering + * Provide more access to the nwg::win32 helper functions + * Add utility functions to edit box for scrolling -Here a few things that I thought about PRing into native-windows-gui: -* Minimize and restore windows -* Maybe enable WS_CLIPSIBLINGS in flags for controls and enable z-ordering -* Provide more access to the nwg::win32 helper functions -* Add utility functions to edit box for scrolling diff --git a/src/main.rs b/src/main.rs index bbbcc47..aa35a0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -215,19 +215,19 @@ pub struct App { impl App { fn on_window_init(&self) { - let _result = self.load_registry_settings(); - self.data.borrow_mut().registry_loaded = true; + self.log.set_text("Starting"); + let result = self.load_registry_settings(); + if let Err(_e) = result { + self.app_log_write(&format!("Registry settings not found")); + } + self.data.borrow_mut().registry_loaded = true; let (min, max) = { let data = self.data.borrow(); (data.graph_min, data.graph_max) }; self.graph.init(GRAPH_BAR_COUNT, min, max); self.graph.on_resize(); - let message = &format!( - "Started at {}", - self.data.borrow().app_start.format("%F at %r") - ); - self.log.set_text(message); + self.app_log_write("Running"); } fn load_registry_settings(&self) -> Result<()> { @@ -242,31 +242,35 @@ impl App { } fn save_registry_settings(&self) -> Result<()> { - let data = self.data.borrow(); - if !data.registry_loaded { + if !self.data.borrow().registry_loaded { bail!("Registry not loaded yet"); } let reg = RegKey::predef(HKEY_CURRENT_USER); - let result = reg.create_subkey("SOFTWARE\\Vivitap\\Contrac"); - let subkey = match result { + let subkey = match reg.create_subkey("SOFTWARE\\Vivitap\\Contrac") { Ok((key, _disposition)) => key, - Err(e) => panic!("Problem creating the file: {:?}", e), + Err(_e) => bail!("Registry read"), }; - subkey.set_value("GraphMin", &(data.graph_min as u32))?; - subkey.set_value("GraphMax", &(data.graph_max as u32))?; + { + let data = self.data.borrow(); + subkey.set_value("GraphMin", &(data.graph_min as u32))?; + subkey.set_value("GraphMax", &(data.graph_max as u32))?; + } Ok(()) } fn on_graph_min_max_change(&self) { let (min, max) = self.graph.get_min_max(); + let mut changed = false; { let mut data = self.data.borrow_mut(); if min != data.graph_min || max != data.graph_max { data.graph_min = min; data.graph_max = max; + changed = true; } } - let _ = self.save_registry_settings(); + if !changed { return; } + if let Err(e) = self.save_registry_settings() { self.app_log_write(&format!("Problem creating the file: {:?}", e)) }; } fn app_log_write(&self, message: &str) {