From e1ac76baf55e9fa5987533d18b76a1bd283b4490 Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Thu, 7 Sep 2023 18:51:30 -0500 Subject: [PATCH 01/12] initial port to avalonia --- .vscode/launch.json | 11 + .vscode/settings.json | 22 ++ SharpFM.App/App.axaml | 10 + SharpFM.App/App.axaml.cs | 27 +++ SharpFM.App/App.xaml | 7 - SharpFM.App/App.xaml.cs | 90 -------- .../Assets/LockScreenLogo.scale-200.png | Bin 1430 -> 0 bytes SharpFM.App/Assets/SplashScreen.scale-200.png | Bin 7700 -> 0 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 2937 -> 0 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 1647 -> 0 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 1255 -> 0 bytes SharpFM.App/Assets/StoreLogo.png | Bin 1451 -> 0 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 3204 -> 0 bytes SharpFM.App/LayoutClipPicker.xaml | 18 -- SharpFM.App/LayoutClipPicker.xaml.cs | 39 ---- SharpFM.App/MainPage.xaml | 124 ----------- SharpFM.App/MainPage.xaml.cs | 201 ------------------ SharpFM.App/MainWindow.axaml | 41 ++++ SharpFM.App/MainWindow.axaml.cs | 13 ++ SharpFM.App/Package.appxmanifest | 36 ---- SharpFM.App/Program.cs | 21 ++ SharpFM.App/Properties/AssemblyInfo.cs | 27 --- SharpFM.App/Properties/Default.rd.xml | 31 --- SharpFM.App/SharpFM.App.csproj | 196 ++--------------- SharpFM.App/ViewModels/MainWindowViewModel.cs | 87 ++++++++ SharpFM.App/ViewModels/ViewModelBase.cs | 15 ++ SharpFM.App/app.manifest | 18 ++ SharpFM.Core/SharpFM.Core.csproj | 4 +- SharpFM.sln | 63 ++---- 29 files changed, 303 insertions(+), 798 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 SharpFM.App/App.axaml create mode 100644 SharpFM.App/App.axaml.cs delete mode 100644 SharpFM.App/App.xaml delete mode 100644 SharpFM.App/App.xaml.cs delete mode 100644 SharpFM.App/Assets/LockScreenLogo.scale-200.png delete mode 100644 SharpFM.App/Assets/SplashScreen.scale-200.png delete mode 100644 SharpFM.App/Assets/Square150x150Logo.scale-200.png delete mode 100644 SharpFM.App/Assets/Square44x44Logo.scale-200.png delete mode 100644 SharpFM.App/Assets/Square44x44Logo.targetsize-24_altform-unplated.png delete mode 100644 SharpFM.App/Assets/StoreLogo.png delete mode 100644 SharpFM.App/Assets/Wide310x150Logo.scale-200.png delete mode 100644 SharpFM.App/LayoutClipPicker.xaml delete mode 100644 SharpFM.App/LayoutClipPicker.xaml.cs delete mode 100644 SharpFM.App/MainPage.xaml delete mode 100644 SharpFM.App/MainPage.xaml.cs create mode 100644 SharpFM.App/MainWindow.axaml create mode 100644 SharpFM.App/MainWindow.axaml.cs delete mode 100644 SharpFM.App/Package.appxmanifest create mode 100644 SharpFM.App/Program.cs delete mode 100644 SharpFM.App/Properties/AssemblyInfo.cs delete mode 100644 SharpFM.App/Properties/Default.rd.xml create mode 100644 SharpFM.App/ViewModels/MainWindowViewModel.cs create mode 100644 SharpFM.App/ViewModels/ViewModelBase.cs create mode 100644 SharpFM.App/app.manifest diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2c4268f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "configurations": [ + { + "name": "C#: SharpFM.App", + "type": "dotnet", + "request": "launch", + "projectPath": "${workspaceFolder}\\SharpFM.App\\SharpFM.App.csproj", + "launchConfigurationId": "TargetFramework=;SharpFM.App" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4fe3b60 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#fa1b49", + "activityBar.background": "#fa1b49", + "activityBar.foreground": "#e7e7e7", + "activityBar.inactiveForeground": "#e7e7e799", + "activityBarBadge.background": "#155e02", + "activityBarBadge.foreground": "#e7e7e7", + "commandCenter.border": "#e7e7e799", + "sash.hoverBorder": "#fa1b49", + "statusBar.background": "#dd0531", + "statusBar.foreground": "#e7e7e7", + "statusBarItem.hoverBackground": "#fa1b49", + "statusBarItem.remoteBackground": "#dd0531", + "statusBarItem.remoteForeground": "#e7e7e7", + "titleBar.activeBackground": "#dd0531", + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveBackground": "#dd053199", + "titleBar.inactiveForeground": "#e7e7e799" + }, + "peacock.color": "#dd0531" +} \ No newline at end of file diff --git a/SharpFM.App/App.axaml b/SharpFM.App/App.axaml new file mode 100644 index 0000000..ac05255 --- /dev/null +++ b/SharpFM.App/App.axaml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/SharpFM.App/App.axaml.cs b/SharpFM.App/App.axaml.cs new file mode 100644 index 0000000..7b0d262 --- /dev/null +++ b/SharpFM.App/App.axaml.cs @@ -0,0 +1,27 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using SharpFM.App.ViewModels; + +namespace SharpFM.App; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow + { + DataContext = new MainWindowViewModel() + }; + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/SharpFM.App/App.xaml b/SharpFM.App/App.xaml deleted file mode 100644 index 9e2ec38..0000000 --- a/SharpFM.App/App.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/SharpFM.App/App.xaml.cs b/SharpFM.App/App.xaml.cs deleted file mode 100644 index 5f747b5..0000000 --- a/SharpFM.App/App.xaml.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; - -namespace SharpFM.App -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - public sealed partial class App : Application - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - this.Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used such as when the application is launched to open a specific file. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs e) - { - Frame rootFrame = Window.Current.Content as Frame; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == null) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - - rootFrame.NavigationFailed += OnNavigationFailed; - - if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - if (e.PrelaunchActivated == false) - { - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - // Ensure the current window is active - Window.Current.Activate(); - } - } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new Exception("Failed to load Page " + e.SourcePageType.FullName); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - var deferral = e.SuspendingOperation.GetDeferral(); - //TODO: Save application state and stop any background activity - deferral.Complete(); - } - } -} diff --git a/SharpFM.App/Assets/LockScreenLogo.scale-200.png b/SharpFM.App/Assets/LockScreenLogo.scale-200.png deleted file mode 100644 index 735f57adb5dfc01886d137b4e493d7e97cf13af3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1430 zcmaJ>TTC2P7~aKltDttVHYH6u8Io4i*}3fO&d$gd*bA_<3j~&e7%8(eXJLfhS!M@! zKrliY>>6yT4+Kr95$!DoD(Qn-5TP|{V_KS`k~E6(LGS@#`v$hQo&^^BKsw3HIsZBT z_y6C2n`lK@apunKojRQ^(_P}Mgewt$(^BBKCTZ;*xa?J3wQ7~@S0lUvbcLeq1Bg4o zH-bvQi|wt~L7q$~a-gDFP!{&TQfc3fX*6=uHv* zT&1&U(-)L%Xp^djI2?~eBF2cxC@YOP$+9d?P&h?lPy-9M2UT9fg5jKm1t$m#iWE{M zIf%q9@;fyT?0UP>tcw-bLkz;s2LlKl2qeP0w zECS7Ate+Awk|KQ+DOk;fl}Xsy4o^CY=pwq%QAAKKl628_yNPsK>?A>%D8fQG6IgdJ ztnxttBz#NI_a@fk7SU`WtrpsfZsNs9^0(2a z@C3#YO3>k~w7?2hipBf{#b6`}Xw1hlG$yi?;1dDs7k~xDAw@jiI*+tc;t2Lflg&bM)0!Y;0_@=w%`LW^8DsYpS#-bLOklX9r?Ei}TScw|4DbpW%+7 zFgAI)f51s}{y-eWb|vrU-Ya!GuYKP)J7z#*V_k^Xo>4!1Yqj*m)x&0L^tg3GJbVAJ zJ-Pl$R=NAabouV=^z_t;^K*0AvFs!vYU>_<|I^#c?>>CR<(T?=%{;U=aI*SbZADLH z&(f2wz_Y0??Tf|g;?|1Znw6}6U43Q#qNRwv1vp9uFn1)V#*4p&%$mP9x&15^OaBiDS(XppT|z^>;B{PLVEbS3IFYV yGvCsSX*m diff --git a/SharpFM.App/Assets/SplashScreen.scale-200.png b/SharpFM.App/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 023e7f1feda78d5100569825acedfd213a0d84e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7700 zcmeHLYj~4Yw%(;oxoEH#Kxq-eR|+VkP17b#Vk;?4QwkI+A{L04G+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l h&G-K)@HZb3BABY{)U1?^%I#E6`MGoTtustd{~yM6srvu` diff --git a/SharpFM.App/Assets/Square150x150Logo.scale-200.png b/SharpFM.App/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index af49fec1a5484db1d52a7f9b5ec90a27c7030186..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2937 zcma)84OCO-8BSud5)jwMLRVKgX(S?$n?Ld|vrsm<$CF7)&zTbyy1FE5bU`Q17MRv`9ue$;R(@8kR;#vJ*IM0>cJIAOte!d7oRgdH zd%ySjdB6L9=gX^A6)VzH7p2l@v~3zJAMw|DFy#^)F@@F*`mqUn=Il>l)8_+ab;nOW{%+iPx z+s{Eu|&pIs)Z7{La9~?xKfyl z#43?gjEL15d4WbOZo#SiP%>DB^+BcnJ=7dHEe;r#G=tuw|ka z%q@}##Uh7;tc%L_64m(kHtw74ty%BJMb)_1)#S0j`)F8_1jF7vScpsnH=0V19bO8y zR`0SjIdCUo&=>JwMQF8KHA<{ODHTiQh}0^@5QRmCA?gOH6_H3K^-_sNB^RrdNuK-R zOO*vOrKCVvDwgUck`kF(E7j{I#iiN;b*ZdCt4m@HPA`EuEqGGf4%!K<;(=I=&Vyrw z%TwcWtxa}8mCZ%Cyf&ActJ6_$ox5z6-D!0-dvnRx6t7y3d+h6QYpKWO;8OdnvERo7 zuEf>ih5`wqY)~o@OeVt-wM?Q!>QzdGRj!bz6fzYrfw$hZfAKzr2-M+D+R>}~oT574c;_3zquHcElqKIsryILt3g8n3jcMb+j?i?-L3FpZJ z2WRVBRdDPc+G5aaYg#5hpE+6nQ|(VSoxT3|biF;BUq#==-27Xi=gihDPYP$7?=9cP zYKE$jeQ|3~_L0VG-(F~2ZPyD0=k{J4Q~h(t__{-mz_w8{JDY9{`1ouzz!Vr5!ECdE z6U~O1k8c}24V7~zzXWTV-Pe4)y}wQJS&q%H5`Fo_f_JvIU489aCX$;P`u#!I-=^4ijC2{&9!O&h>mi?9oYD=GC#%)6{GzN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4(epJ78uh5nDlX8(TxzDYwP diff --git a/SharpFM.App/Assets/Square44x44Logo.scale-200.png b/SharpFM.App/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index ce342a2ec8a61291ba76c54604aea7e9d20af11b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1647 zcmaJ?eM}Q)7(e+G1Q(|`V9JhTI2>MkceK4;p;PR&$Pi?ejk3YQ_3o`S&|W_dsOZ8# zWPTt69g`t$ab`0cj-Y0yiBSOqmd)tG7G(}M5aP0_%&9TijB#&)I{zSE^4@#z^FF`l z`8{8`o%wlL(UI|y2!cdsuVamHH~H86F!*-15em4)NqUpCQM5?aoC_eCf@lV4wvF2a zjDQn1JBL69f&@2M3rvzJcfE!eZ8FZUBlFlC5RD)it33{mF9#B82AiyQE%w)`vlwa> zv{<1sm&kSKK$&%2jSFn7$t&P%%6Ue>R=EAnG8N7fqynWG8L3p!4801a;8{+nliO(qd(jNJ_?+9W3#hLIDLoT6~3fx9=`CC-D}-AMrpEO7HK zt3$GicGPc?GmDjy7K2P@La;eu4!$zWCZ`ym{Z$b zu-O6RM&K4JT|BIZB`E-gxqG%FzanI#+2FFmqHqXG7yxWB=w55RGOM)$xMb(>kSNR z2w=1AZi%z=AmG~yea~XaXJR!v7vLn(RUnELfiB1|6D84ICOS}^Zo2AdN}<&*h}G_u z{xZ!(%>tLT3J3<5XhWy-tg+6)0nmUUENLW8TWA{R6bgVd3X;anYFZ^IRis*_P-C-r z;i>%1^eL3UI2-{w8nuFFcs0e~7J{O2k^~Ce%+Ly4U?|=!0LH=t6()xi<^I-rs+9sF z*q{E-CxZbGPeu#a;XJwE;9S1?#R&uns>^0G3p`hEUF*v`M?@h%T%J%RChmD|EVydq zmHWh*_=S%emRC*mhxaVLzT@>Z2SX0u9v*DIJ@WC^kLVdlGV6LpK$KIrlJqc zpJ921)+3JJdTx|<`G&kXpKkjGJv=76R`yYIQ{#c-`%+`#V(7}Q;&@6U8!Td1`d;?N z_9mnI#?AA}4J!r)LN4!E-@H5eXauuB7TOawS>Y|{-P?NNx-lq+z1W-+y(;39P&&LP zL{N80?&=C*qKmdA^moMZRuPcD!B<*mq$ch=0Cnlitw#txRWhb3%TQvPqjkC`F69G4b! ze7z9MZ#+;_#l?H37UqUhDFb^l&s2{oM$3I0o^Q!yx;;V)QmCMo)Tb_ui|mit8MS?U zm##6$sZZ1$@|s%?l@>4Z<*Q}sRBSKMhb4I{e5LdEhsHIHTe8Bod5c>6QtT>$XgUBz z6MK`kO$=jmt@FqggOhJ5j~e@ygRbG;<{Vu)*+nn9aQeo0;$#j;|MS=S$&L?BeV25z xs3B`@=#`5TF{^6(A1rvdY@|-RtQ|iS5{tyX+wH?;n8E)G$kykv-D^wh{{!TZT%7;_ diff --git a/SharpFM.App/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/SharpFM.App/Assets/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index f6c02ce97e0a802b85f6021e822c89f8bf57d5cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1255 zcmaJ>TWs4@7*5+{G#S+&C!qC#> zf>5N3P6jO*Cz>ug*(_DmW=)kea&m$gZ^+nyiF`;j%w@}y8)>p*SH}C`m?DXeieF2U zyQHecc_L%Gh!7GMt+hG06y;+|p4>m~}PjA}rKViGiEnn7G0ZO<>G|7q;2?NwGCM3s?eued6%hd$B+ z*kQJ{#~$S=DFE(%=E+UkmlEI*%3llUf~8Ja9YU1Vui0IbGBkW_gHB%Rd&!!ioX zs40O?i9I{};kle7GMvE7(rk`la=gTI)47=>%?q@^iL-nUo3}h4S}N-KHn8t5mVP8w z&bSErwp+37 zNJJ8?a|{r5Q3R0Z5s-LB1WHOwYC@7pCHWND#cL1cZ?{kJ368_*(UDWUDyb<}0y@o# zfMF016iMWPCb6obAxT$JlB6(2DrlXDTB&!0`!m??4F(qWMhjVZo?JXQmz`1*58Z=& zcDmB|S-E@j?BoFGix0flckqdS4jsPNzhfWyWIM98GxcLs89C(~dw%$_t;JjX-SD}E zfiGV;{8Q%8r}w9x>EEigW81>`kvnU@pK)4+xk9@+bNj9L!AAZ@SZ@q|)&BmY3+HZx zul~BeG4|}-;L%cHViQGQX?^zFfO0&#cHwel=d`lH9sJ-@Sl@n*(8J2>%Ac`IxyY?Q z{=GhWvC#gu-~Ia7*n{=+;qM?Ul_wy1+u7ho;=`>EwP^g~R@{unBds`!#@}tluZQpS zm)M~nYEifJWJGx?_6DcTy>#uh%>!H9=hb^(v`=m3F1{L>db=<5_tm+_&knAQ2EU$s Mu9UqpbNZeC0BbUo^Z)<= diff --git a/SharpFM.App/Assets/StoreLogo.png b/SharpFM.App/Assets/StoreLogo.png deleted file mode 100644 index 7385b56c0e4d3c6b0efe3324aa1194157d837826..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1451 zcmaJ>eN5D57_Z|bH;{0+1#mbl)eTU3{h)Wf7EZV?;HD@XL@{B`Ui%(2aMxQ~xdXSv z5nzWi(LW)U2=Vc-cY@s7nPt{i0hc6!7xN4NNHI#EQl>YNBy8l4%x9gr_W-j zEZMQmmTIy(>;lblRfh`dIyTgc9W5d!VP$L4(kKrN1c5G~(O_#xG zAJCNTstD^5SeXFB+&$h=ToJP2H>xr$iqPs-#O*;4(!Fjw25-!gEb*)mU}=)J;Iu>w zxK(5XoD0wrPSKQ~rbL^Cw6O_03*l*}i=ydbu7adJ6y;%@tjFeXIXT+ms30pmbOP%Q zX}S;+LBh8Tea~TSkHzvX6$rYb)+n&{kSbIqh|c7hmlxmwSiq5iVhU#iEQ<>a18|O^Sln-8t&+t`*{qBWo5M?wFM(JuimAOb5!K#D}XbslM@#1ZVz_;!9U zpfEpLAOz=0g@bd6Xj_ILi-x^!M}73h^o@}hM$1jflTs|Yuj9AL@A3<-?MV4!^4q`e z)fO@A;{9K^?W?DbnesnPr6kK>$zaKo&;FhFd(GYFCIU^T+OIMb%Tqo+P%oq(IdX7S zf6+HLO?7o0m+p>~Tp5UrXWh!UH!wZ5kv!E`_w)PTpI(#Iw{AS`gH4^b(bm^ZCq^FZ zY9DD7bH}rq9mg88+KgA$Zp!iWncuU2n1AuIa@=sWvUR-s`Qb{R*kk(SPU^`$6BXz8 zn#7yaFOIK%qGxyi`dYtm#&qqox0$h=pNi#u=M8zUG@bpiZ=3sT=1}Trr}39cC)H|v zbL?W)=&s4zrh)7>L(|cc%$1#!zfL?HjpeP%T+x_a+jZ16b^iKOHxFEX$7d|8${H-* zIrOJ5w&i$>*D>AKaIoYg`;{L@jM((Kt?$N$5OnuPqVvq**Nm}(f0wwOF%iX_Pba;V z;m@wxX&NcV3?<1+u?A{y_DIj7#m3Af1rCE)o`D&Y3}0%7E;iX1yMDiS)sh0wKi!36 zL!Wmq?P^Ku&rK~HJd97KkLTRl>ScGFYZNlYytWnhmuu|)L&ND8_PmkayQb{HOY640 bno1(wj@u8DCVuFR|31B*4ek@pZJqxCDDe1x diff --git a/SharpFM.App/Assets/Wide310x150Logo.scale-200.png b/SharpFM.App/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 288995b397fdbef1fb7e85afd71445d5de1952c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3204 zcmbVPeQXow8NYmBd90>}0NP?GhXW~VaeThm=a0tV#EwJMI!)6M3}|c4_Bl3=Kd>G0 z(GHx1wl<7(tP?FsOQkTilSo*iIvF%uArExJ73~P zSv1xEy!U(Wd4A9D`FQV@W3@F^qJ@PEF$@z`Z!*BbFsS(^?B zyiAzJ+q})bkgiQHWqEb*jJD-coHYr1^iocg)l!Qa{Xqs-l~6J}p-|##ZHYofskQ3$ zI0;xzXyhazBeXhIsg5A=%ufo@f)1yy&ScKS0;HF^!r_2UE^lpZEom(+@duma3awTv zCrCL-%D_SvYWIcdHkmI}#50(fkUi)Qgx!80ju>g1za^}ff>JI8Z@^-iCiaCgg@TgF z+vtE?Q9{VQUX&MW9SYYmGcxA14%N2@7FwBTD4N<(2{nWgV8$e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PrTLQ2Uzysx>UV=V zk^RrDSvdQ?0;=hY67EgII-f4`t=+i*yS=Y~!XlqIy_4x&%+OdfbKOFPXS2X5%4R{N z$SQMX^AK6(fA - - - - - diff --git a/SharpFM.App/LayoutClipPicker.xaml.cs b/SharpFM.App/LayoutClipPicker.xaml.cs deleted file mode 100644 index 6cb8ac1..0000000 --- a/SharpFM.App/LayoutClipPicker.xaml.cs +++ /dev/null @@ -1,39 +0,0 @@ -using SharpFM.Core; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 - -namespace SharpFM.App -{ - public sealed partial class LayoutClipPicker : ContentDialog - { - public FileMakerClip DialogResult { get; private set; } - - public LayoutClipPicker() - { - this.InitializeComponent(); - } - - private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) - { - DialogResult = LayoutPickerCombo.SelectedItem as FileMakerClip; - } - - private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) - { - } - } -} diff --git a/SharpFM.App/MainPage.xaml b/SharpFM.App/MainPage.xaml deleted file mode 100644 index ecdf680..0000000 --- a/SharpFM.App/MainPage.xaml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SharpFM.App/MainPage.xaml.cs b/SharpFM.App/MainPage.xaml.cs deleted file mode 100644 index d19eacc..0000000 --- a/SharpFM.App/MainPage.xaml.cs +++ /dev/null @@ -1,201 +0,0 @@ -using SharpFM.Core; -using System; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; -using Windows.ApplicationModel.DataTransfer; -using Windows.Storage.Streams; -using Windows.UI.Core; -using Windows.UI.Popups; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; - -// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 - -namespace SharpFM.App -{ - ///

- /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class MainPage : Page - { - public ObservableCollection Keys { get; } - - public ObservableCollection Layouts { get; } - - public FileMakerClip SelectedLayout { get; set; } - public FileMakerClip SelectedClip { get; set; } - - public string SelectedClipAsCsharp { get; set; } - - CoreWindow window; - - public MainPage() - { - InitializeComponent(); - - window = CoreWindow.GetForCurrentThread(); - window.Activated += Window_Activated; - - Keys = new ObservableCollection(); - Layouts = new ObservableCollection(); - - Keys.CollectionChanged += (sender, e) => - { - Layouts.Clear(); - foreach (var layout in Keys.Where(k => FileMakerClip.ClipTypes[k.ClipboardFormat] == "Layout")) - { - Layouts.Add(layout); - } - }; - - Clipboard.ContentChanged += Clipboard_ContentChanged; - } - - private async Task ProcessClipboard() - { - try - { - var clip = Clipboard.GetContent(); - - var formats = clip.AvailableFormats.Where(f => f.StartsWith("Mac-", StringComparison.CurrentCultureIgnoreCase)).Distinct(); - - Debug.WriteLine($"Formats: {formats.Count()}"); - - foreach (var format in formats) - { - object clipData = null; - - try - { - if (format.Equals("bitmap", StringComparison.CurrentCultureIgnoreCase)) - { - clipData = await clip.GetBitmapAsync(); - } - clipData = await clip.GetDataAsync(format); - } -#pragma warning disable CA1031 // Do not catch general exception types - catch (Exception ex) -#pragma warning restore CA1031 // Do not catch general exception types - { - Debug.WriteLine(ex.Message); - } - - if (!(clipData is IRandomAccessStream dataObj)) - { - // this is some type of clipboard data this program can't handle - continue; - } - - var stream = dataObj.GetInputStreamAt(0); - IBuffer buff = new Windows.Storage.Streams.Buffer((uint)dataObj.Size); - await stream.ReadAsync(buff, (uint)dataObj.Size, InputStreamOptions.None); - var buffArray = buff.ToArray(); - - var fmclip = new FileMakerClip("new-clip", format, buffArray); - - // don't bother adding a duplicate. For some reason entries were getting entered twice per clip - // this is not the most efficient method to detect it, but it works well enough for now - if (Keys.Any(k => k.XmlData == fmclip.XmlData)) - { - continue; - } - - Keys.Add(fmclip); - } - } - catch (Exception ex) - { - var md = new MessageDialog(ex.Message + "\r\n" + ex.StackTrace); - await md.ShowAsync(); - } - } - - private async void Window_Activated(CoreWindow sender, WindowActivatedEventArgs args) - { - await ProcessClipboard(); - } - - private void Clipboard_ContentChanged(object sender, object e) - { - window.Activate(); - } - - private void Button_Click_1(object sender, RoutedEventArgs e) - { - var dp = new DataPackage(); - - if (!(mdv.SelectedItem is FileMakerClip data)) - { - return; // no data - } - - // recalculate the length of the original text and make sure that is the first four bytes in the stream - //var code = data.RawData;// XamlCodeRenderer.Text; - //byte[] byteList = Encoding.UTF8.GetBytes(code); - //int bl = byteList.Length; - //byte[] intBytes = BitConverter.GetBytes(bl); - - //dp.SetData("Mac-XMSS", intBytes.Concat(byteList).ToArray().AsBuffer().AsStream().AsRandomAccessStream()); - dp.SetData(data.ClipboardFormat, data.RawData.AsBuffer().AsStream().AsRandomAccessStream()); - - Clipboard.SetContent(dp); - Clipboard.Flush(); - } - - private void masterNewScript_Click(object sender, RoutedEventArgs e) - { - Keys.Add(new FileMakerClip("", "Mac-XMSS", Array.Empty())); - } - - private async void asModelAppBarButton_Click(object sender, RoutedEventArgs e) - { - // TODO: improve the UX of this whole thing. This works as a hack for proving the concept, but it could be so much better. - var data = mdv.SelectedItem as FileMakerClip; - - var md = new MessageDialog("Do you want to use a layout to limit the number of fields in the generated model?", "Use Layout Projection?"); - // setup the command that will show the Layout picker and generate content that way - md.Commands.Add(new UICommand("Use Layout", new UICommandInvokedHandler(async uic => - { - var picker = new LayoutClipPicker - { - DataContext = this.DataContext - }; - var pickerResult = await picker.ShowAsync(ContentDialogPlacement.InPlace); - if (pickerResult == ContentDialogResult.Primary) - { - // regenerate using the layout picker - SelectedLayout = picker.DialogResult; - - var classString = data.CreateClass(SelectedLayout); - var dp = new DataPackage(); - dp.SetText(classString); - Clipboard.SetContent(dp); - Clipboard.Flush(); - } - }))); - - // setup the command that will generate the full model - md.Commands.Add(new UICommand("No Projection", new UICommandInvokedHandler(uic => - { - var classString = data.CreateClass(); - var dp = new DataPackage(); - dp.SetText(classString); - Clipboard.SetContent(dp); - Clipboard.Flush(); - }))); - - var result = await md.ShowAsync(); - } - - //private void LayoutPickerComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) - //{ - // SelectedLayout = ((ComboBox)sender).SelectedItem as FileMakerClip; - //} - } -} \ No newline at end of file diff --git a/SharpFM.App/MainWindow.axaml b/SharpFM.App/MainWindow.axaml new file mode 100644 index 0000000..87d7dfe --- /dev/null +++ b/SharpFM.App/MainWindow.axaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SharpFM.App/MainWindow.axaml.cs b/SharpFM.App/MainWindow.axaml.cs new file mode 100644 index 0000000..946d770 --- /dev/null +++ b/SharpFM.App/MainWindow.axaml.cs @@ -0,0 +1,13 @@ +using System.Collections.ObjectModel; +using Avalonia.Controls; +using SharpFM.Core; + +namespace SharpFM.App; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/SharpFM.App/Package.appxmanifest b/SharpFM.App/Package.appxmanifest deleted file mode 100644 index 360ba59..0000000 --- a/SharpFM.App/Package.appxmanifest +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - SharpFM.App - Nate.B - Assets\StoreLogo.png - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SharpFM.App/Program.cs b/SharpFM.App/Program.cs new file mode 100644 index 0000000..e57d73d --- /dev/null +++ b/SharpFM.App/Program.cs @@ -0,0 +1,21 @@ +using Avalonia; +using System; + +namespace SharpFM.App; + +class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace(); +} diff --git a/SharpFM.App/Properties/AssemblyInfo.cs b/SharpFM.App/Properties/AssemblyInfo.cs deleted file mode 100644 index 99d99f9..0000000 --- a/SharpFM.App/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SharpFM.App")] -[assembly: AssemblyDescription("FileMaker Developer Utility")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nate Bross")] -[assembly: AssemblyProduct("SharpFM.App")] -[assembly: AssemblyCopyright("Copyright © Nate Bross 2018")] -[assembly: AssemblyTrademark("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/SharpFM.App/Properties/Default.rd.xml b/SharpFM.App/Properties/Default.rd.xml deleted file mode 100644 index dd97dcf..0000000 --- a/SharpFM.App/Properties/Default.rd.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/SharpFM.App/SharpFM.App.csproj b/SharpFM.App/SharpFM.App.csproj index ed8513c..0a0dd74 100644 --- a/SharpFM.App/SharpFM.App.csproj +++ b/SharpFM.App/SharpFM.App.csproj @@ -1,176 +1,26 @@ - - - + - Debug - x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176} - AppContainerExe - Properties - SharpFM.App - SharpFM.App - en-US - UAP - 10.0.18362.0 - 10.0.18362.0 - 14 - 512 - {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - true - False - True - Always - x86|x64|arm - 1 - OnApplicationRun - - - true - bin\x86\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x86 - false - prompt - true - false - true - - - bin\x86\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x86 - false - prompt - true - true - - - true - bin\ARM\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - ARM - false - prompt - true - - - bin\ARM\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - ARM - false - prompt - true - true - - - true - bin\x64\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x64 - false - prompt - true - - - bin\x64\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x64 - false - prompt - true - true - - - PackageReference - - - - App.xaml - - - LayoutClipPicker.xaml - - - MainPage.xaml - - - - - - Designer - - - - - - - - - - - - + WinExe + net6.0 + enable + true + app.manifest + true + + + - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - + + + + + + + + + + + + - - - 4.0.2 - - - 2.9.3 - - - 6.2.9 - - - 5.1.1 - - - 0.8.1-alpha - - - - - {a4b965d1-9011-4074-a2ba-d5532462defb} - SharpFM.Core - - - - 14.0 - - - - \ No newline at end of file + diff --git a/SharpFM.App/ViewModels/MainWindowViewModel.cs b/SharpFM.App/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..d399b31 --- /dev/null +++ b/SharpFM.App/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SharpFM.Core; + +namespace SharpFM.App.ViewModels; + +public partial class MainWindowViewModel : ViewModelBase +{ + public MainWindowViewModel() + { + Keys = new ObservableCollection(); + } + + [ObservableProperty] private string? _text; + + [RelayCommand] + private async Task PasteText(CancellationToken token) + { + ErrorMessages?.Clear(); + try + { + await DoGetClipboardDataAsync(); + } + catch (Exception e) + { + ErrorMessages?.Add(e.Message); + } + } + private async Task DoGetClipboardDataAsync() + { + // For learning purposes, we opted to directly get the reference + // for StorageProvider APIs here inside the ViewModel. + + // For your real-world apps, you should follow the MVVM principles + // by making service classes and locating them with DI/IoC. + + // See DepInject project for a sample of how to accomplish this. + if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop || + desktop.MainWindow?.Clipboard is not { } provider) + throw new NullReferenceException("Missing Clipboard instance."); + + var formats = await provider.GetFormatsAsync(); + + foreach (var format in formats.Where(f => f.StartsWith("Mac-", StringComparison.CurrentCultureIgnoreCase)).Distinct()) + { + if (string.IsNullOrEmpty(format)) { continue; } + + object clipData = await provider.GetDataAsync(format); + + if (!(clipData is byte[] dataObj)) + { + // this is some type of clipboard data this program can't handle + continue; + } + + var clip = new FileMakerClip("new-clip", format, dataObj); + + // don't bother adding a duplicate. For some reason entries were getting entered twice per clip + // this is not the most efficient method to detect it, but it works well enough for now + if (Keys.Any(k => k.XmlData == clip.XmlData)) + { + continue; + } + + Keys.Add(clip); + } + } + + [ObservableProperty] + private ObservableCollection? _keys; + + //public ObservableCollection Layouts { get; } + + [ObservableProperty] + private FileMakerClip? _selectedLayout; + + [ObservableProperty] + private FileMakerClip? _selectedClip; +} \ No newline at end of file diff --git a/SharpFM.App/ViewModels/ViewModelBase.cs b/SharpFM.App/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..b1efc30 --- /dev/null +++ b/SharpFM.App/ViewModels/ViewModelBase.cs @@ -0,0 +1,15 @@ +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; + +namespace SharpFM.App.ViewModels; + +public partial class ViewModelBase : ObservableObject +{ + protected ViewModelBase() + { + ErrorMessages = new ObservableCollection(); + } + + [ObservableProperty] + private ObservableCollection? _errorMessages; +} \ No newline at end of file diff --git a/SharpFM.App/app.manifest b/SharpFM.App/app.manifest new file mode 100644 index 0000000..4395fbb --- /dev/null +++ b/SharpFM.App/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/SharpFM.Core/SharpFM.Core.csproj b/SharpFM.Core/SharpFM.Core.csproj index 881fdc1..05b9a7a 100644 --- a/SharpFM.Core/SharpFM.Core.csproj +++ b/SharpFM.Core/SharpFM.Core.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/SharpFM.sln b/SharpFM.sln index 1226d8c..8052de7 100644 --- a/SharpFM.sln +++ b/SharpFM.sln @@ -1,65 +1,28 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2003 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpFM.App", "SharpFM.App\SharpFM.App.csproj", "{374EAAF0-E0DA-4270-85E8-35BC6B7C7176}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpFM.App", "SharpFM.App\SharpFM.App.csproj", "{5245F468-DAD7-478C-8E5F-518A03664F71}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpFM.Core", "SharpFM.Core\SharpFM.Core.csproj", "{A4B965D1-9011-4074-A2BA-D5532462DEFB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpFM.Core", "SharpFM.Core\SharpFM.Core.csproj", "{9E4B6169-0E69-430A-BF6C-184A10C71F9B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|Any CPU.ActiveCfg = Debug|x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|ARM.ActiveCfg = Debug|ARM - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|ARM.Build.0 = Debug|ARM - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|ARM.Deploy.0 = Debug|ARM - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|x64.ActiveCfg = Debug|x64 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|x64.Build.0 = Debug|x64 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|x64.Deploy.0 = Debug|x64 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|x86.ActiveCfg = Debug|x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|x86.Build.0 = Debug|x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Debug|x86.Deploy.0 = Debug|x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|Any CPU.ActiveCfg = Release|x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|ARM.ActiveCfg = Release|ARM - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|ARM.Build.0 = Release|ARM - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|ARM.Deploy.0 = Release|ARM - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|x64.ActiveCfg = Release|x64 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|x64.Build.0 = Release|x64 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|x64.Deploy.0 = Release|x64 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|x86.ActiveCfg = Release|x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|x86.Build.0 = Release|x86 - {374EAAF0-E0DA-4270-85E8-35BC6B7C7176}.Release|x86.Deploy.0 = Release|x86 - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|ARM.ActiveCfg = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|ARM.Build.0 = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|x64.ActiveCfg = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|x64.Build.0 = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|x86.ActiveCfg = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Debug|x86.Build.0 = Debug|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|Any CPU.Build.0 = Release|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|ARM.ActiveCfg = Release|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|ARM.Build.0 = Release|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|x64.ActiveCfg = Release|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|x64.Build.0 = Release|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|x86.ActiveCfg = Release|Any CPU - {A4B965D1-9011-4074-A2BA-D5532462DEFB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {004282D1-59D0-4C95-94DF-12832394F245} + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5245F468-DAD7-478C-8E5F-518A03664F71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5245F468-DAD7-478C-8E5F-518A03664F71}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5245F468-DAD7-478C-8E5F-518A03664F71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5245F468-DAD7-478C-8E5F-518A03664F71}.Release|Any CPU.Build.0 = Release|Any CPU + {9E4B6169-0E69-430A-BF6C-184A10C71F9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E4B6169-0E69-430A-BF6C-184A10C71F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E4B6169-0E69-430A-BF6C-184A10C71F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E4B6169-0E69-430A-BF6C-184A10C71F9B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal From 5bdf802f6305ac97a6d5d61ab255004fcc30ca1d Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Fri, 8 Sep 2023 12:53:35 -0500 Subject: [PATCH 02/12] clean up; latest C#; add avaloniaedit --- .vscode/settings.json | 13 +- SharpFM.App/App.axaml | 1 + SharpFM.App/MainWindow.axaml | 29 ++- SharpFM.App/MainWindow.axaml.cs | 5 + SharpFM.App/SharpFM.App.csproj | 3 +- SharpFM.App/ViewModels/MainWindowViewModel.cs | 7 +- SharpFM.Core/FileMakerClip.cs | 241 +++++++++--------- SharpFM.Core/FileMakerClipExtensions.cs | 2 +- SharpFM.Core/FileMakerField.cs | 10 +- SharpFM.Core/SharpFM.Core.csproj | 2 + 10 files changed, 175 insertions(+), 138 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 4fe3b60..00609b4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,5 +18,16 @@ "titleBar.inactiveBackground": "#dd053199", "titleBar.inactiveForeground": "#e7e7e799" }, - "peacock.color": "#dd0531" + "peacock.color": "#dd0531", + "cSpell.words": [ + "Avalonia", + "filemaker", + "fmxmlsnippet", + "Mvvm", + "xdoc", + "XMFD", + "XMSC", + "XMSS", + "XMTB" + ] } \ No newline at end of file diff --git a/SharpFM.App/App.axaml b/SharpFM.App/App.axaml index ac05255..0787534 100644 --- a/SharpFM.App/App.axaml +++ b/SharpFM.App/App.axaml @@ -6,5 +6,6 @@ + \ No newline at end of file diff --git a/SharpFM.App/MainWindow.axaml b/SharpFM.App/MainWindow.axaml index 87d7dfe..fb41baa 100644 --- a/SharpFM.App/MainWindow.axaml +++ b/SharpFM.App/MainWindow.axaml @@ -3,7 +3,8 @@ xmlns:vm="using:SharpFM.App.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit" + mc:Ignorable="d" d:DesignWidth="700" d:DesignHeight="500" x:DataType="vm:MainWindowViewModel" x:Class="SharpFM.App.MainWindow" Title="SharpFM"> @@ -11,10 +12,16 @@ - + + - + + - + + + + + + \ No newline at end of file diff --git a/SharpFM.App/MainWindow.axaml.cs b/SharpFM.App/MainWindow.axaml.cs index 946d770..6559166 100644 --- a/SharpFM.App/MainWindow.axaml.cs +++ b/SharpFM.App/MainWindow.axaml.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.ObjectModel; using Avalonia.Controls; +using AvaloniaEdit; using SharpFM.Core; namespace SharpFM.App; @@ -9,5 +11,8 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); + + var editor = this.FindControl("avaloniaEditor") ?? throw new Exception("no control"); + editor.Document = new AvaloniaEdit.Document.TextDocument("Hello world"); } } \ No newline at end of file diff --git a/SharpFM.App/SharpFM.App.csproj b/SharpFM.App/SharpFM.App.csproj index 0a0dd74..a9f0115 100644 --- a/SharpFM.App/SharpFM.App.csproj +++ b/SharpFM.App/SharpFM.App.csproj @@ -3,18 +3,19 @@ WinExe net6.0 enable + latest true app.manifest true - + diff --git a/SharpFM.App/ViewModels/MainWindowViewModel.cs b/SharpFM.App/ViewModels/MainWindowViewModel.cs index d399b31..e0dfaf2 100644 --- a/SharpFM.App/ViewModels/MainWindowViewModel.cs +++ b/SharpFM.App/ViewModels/MainWindowViewModel.cs @@ -4,7 +4,6 @@ using System.Threading; using System.Threading.Tasks; using Avalonia; -using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -53,7 +52,7 @@ private async Task DoGetClipboardDataAsync() { if (string.IsNullOrEmpty(format)) { continue; } - object clipData = await provider.GetDataAsync(format); + object? clipData = await provider.GetDataAsync(format); if (!(clipData is byte[] dataObj)) { @@ -63,6 +62,8 @@ private async Task DoGetClipboardDataAsync() var clip = new FileMakerClip("new-clip", format, dataObj); + if(clip is null) { continue; } + // don't bother adding a duplicate. For some reason entries were getting entered twice per clip // this is not the most efficient method to detect it, but it works well enough for now if (Keys.Any(k => k.XmlData == clip.XmlData)) @@ -75,7 +76,7 @@ private async Task DoGetClipboardDataAsync() } [ObservableProperty] - private ObservableCollection? _keys; + private ObservableCollection _keys; //public ObservableCollection Layouts { get; } diff --git a/SharpFM.Core/FileMakerClip.cs b/SharpFM.Core/FileMakerClip.cs index b74d46c..ad0fb09 100644 --- a/SharpFM.Core/FileMakerClip.cs +++ b/SharpFM.Core/FileMakerClip.cs @@ -7,11 +7,11 @@ using System.Xml; using System.Xml.Linq; -namespace SharpFM.Core +namespace SharpFM.Core; + +public class FileMakerClip { - public class FileMakerClip - { - public static Dictionary ClipTypes { get; set; } = new Dictionary + public static Dictionary ClipTypes { get; set; } = new Dictionary { { "Mac-XMSS", "ScriptSteps" }, { "Mac-XML2", "Layout" }, @@ -20,143 +20,142 @@ public class FileMakerClip { "Mac-XMSC", "Script" } }; - /// - /// Constructor taking in the raw data byte array. - /// - /// The name of the clip. - /// Format of the clip. - /// Data containing the clip. - public FileMakerClip(string name, string format, byte[] data) + /// + /// Constructor taking in the raw data byte array. + /// + /// The name of the clip. + /// Format of the clip. + /// Data containing the clip. + public FileMakerClip(string name, string format, byte[] data) + { + // pull in the name + Name = name; + // load the format + ClipboardFormat = format; + // skip the first four bytes, as this is a length check + XmlData = ClipBytesToPrettyXml(data.Skip(4)); + + // if the data is empty, move on. + if (string.IsNullOrEmpty(XmlData)) { return; } + + // try to show better "name" if possible + var xdoc = XDocument.Load(new StringReader(XmlData)); + var containerName = xdoc.Element("fmxmlsnippet")?.Descendants().First()?.Attribute("name")?.Value; + if (!string.IsNullOrEmpty(containerName)) { - // pull in the name - Name = name; - // load the format - ClipboardFormat = format; - // skip the first four bytes, as this is a length check - XmlData = ClipBytesToPrettyXml(data.Skip(4)); - - // if the data is empty, move on. - if (string.IsNullOrEmpty(XmlData)) { return; } - - // try to show better "name" if possible - var xdoc = XDocument.Load(new StringReader(XmlData)); - var containerName = xdoc.Element("fmxmlsnippet")?.Descendants().First()?.Attribute("name")?.Value; - if (!string.IsNullOrEmpty(containerName)) - { - Name = containerName; - } + Name = containerName; } + } - /// - /// Clipboard Format - /// - public string ClipboardFormat { get; set; } + /// + /// Clipboard Format + /// + public string ClipboardFormat { get; set; } - /// - /// Name of Clip - /// - public string Name { get; set; } + /// + /// Name of Clip + /// + public string Name { get; set; } - /// - /// Raw data that can be put back onto the Clipboard in FileMaker structure. - /// - public byte[] RawData + /// + /// Raw data that can be put back onto the Clipboard in FileMaker structure. + /// + public byte[] RawData + { + get { - get - { - // recalculate the length of the original text and make sure that is the first four bytes in the stream - byte[] byteList = Encoding.UTF8.GetBytes(XmlData); - int bl = byteList.Length; - byte[] intBytes = BitConverter.GetBytes(bl); - return intBytes.Concat(byteList).ToArray(); - } + // recalculate the length of the original text and make sure that is the first four bytes in the stream + byte[] byteList = Encoding.UTF8.GetBytes(XmlData); + int bl = byteList.Length; + byte[] intBytes = BitConverter.GetBytes(bl); + return intBytes.Concat(byteList).ToArray(); } + } - /// - /// The actual clip. Users work with the Xml version here, and then pull the RawData property when ready to write back to FileMaker. - /// - public string XmlData { get; set; } + /// + /// The actual clip. Users work with the Xml version here, and then pull the RawData property when ready to write back to FileMaker. + /// + public string XmlData { get; set; } - /// - /// The fields exposed through this FileMaker Clip (if its a table or a layout). - /// - public IEnumerable Fields + /// + /// The fields exposed through this FileMaker Clip (if its a table or a layout). + /// + public IEnumerable Fields + { + get { - get - { - var xdoc = XDocument.Parse(XmlData); - - switch (ClipTypes[ClipboardFormat]) - { - case "Table": // When we have a table, we can get rich metadata from the clipboard data. - return xdoc - .Descendants("BaseTable") - .Elements("Field") - .Select(x => new FileMakerField - { - FileMakerFieldId = int.Parse(x.Attribute("id").Value), - Name = x.Attribute("name").Value, - DataType = x.Attribute("dataType").Value, - FieldType = x.Attribute("fieldType").Value, - NotEmpty = bool.Parse(x.Element("Validation")?.Element("NotEmpty")?.Attribute("value").Value ?? "false"), - Unique = bool.Parse(x.Element("Validation")?.Element("Unique")?.Attribute("value").Value ?? "false"), - Comment = x.Element("Comment")?.Value, - }); - - case "Layout": // on a layout we only have the field name (TABLE::FIELD) to go on, so we do that. - return xdoc - .Descendants("Object") - .Where(x => x.Attribute("type").Value == "Field") - .Descendants("FieldObj") - .Elements("Name") - .Select(x => new FileMakerField { Name = Regex.Split(x.Value, "::")[1]}); - } - - // return emptyl ist of we don't have a matching type - return new List(); - } - } + var xdoc = XDocument.Parse(XmlData); - /// - /// Utility method for prettifying the Xml for a user to read. - /// - /// The byte array containing the xml data. - /// A prettified version of the byte array as a formatted xml string. - public static string ClipBytesToPrettyXml(IEnumerable clipData) - { - var xmlComments = Encoding.UTF8.GetString(clipData.ToArray()); - if (string.IsNullOrEmpty(xmlComments)) + switch (ClipTypes[ClipboardFormat]) { - // dont try to prettify if we don't have content - return xmlComments; + case "Table": // When we have a table, we can get rich metadata from the clipboard data. + return xdoc + .Descendants("BaseTable") + .Elements("Field") + .Select(x => new FileMakerField + { + FileMakerFieldId = int.Parse(x.Attribute("id").Value), + Name = x.Attribute("name").Value, + DataType = x.Attribute("dataType").Value, + FieldType = x.Attribute("fieldType").Value, + NotEmpty = bool.Parse(x.Element("Validation")?.Element("NotEmpty")?.Attribute("value").Value ?? "false"), + Unique = bool.Parse(x.Element("Validation")?.Element("Unique")?.Attribute("value").Value ?? "false"), + Comment = x.Element("Comment")?.Value, + }); + + case "Layout": // on a layout we only have the field name (TABLE::FIELD) to go on, so we do that. + return xdoc + .Descendants("Object") + .Where(x => x.Attribute("type").Value == "Field") + .Descendants("FieldObj") + .Elements("Name") + .Select(x => new FileMakerField { Name = Regex.Split(x.Value, "::")[1] }); } - return PrettyXml(xmlComments); + + // return empty list of we don't have a matching type + return new List(); } + } - /// - /// Make an Xml string pretty. - /// - /// Raw xml to make pretty. - /// A pretty (human readable) version of the input string. - private static string PrettyXml(string xml) + /// + /// Utility method for prettifying the Xml for a user to read. + /// + /// The byte array containing the xml data. + /// A prettified version of the byte array as a formatted xml string. + public static string ClipBytesToPrettyXml(IEnumerable clipData) + { + var xmlComments = Encoding.UTF8.GetString(clipData.ToArray()); + if (string.IsNullOrEmpty(xmlComments)) { - var stringBuilder = new StringBuilder(); + // don't try to prettify if we don't have content + return xmlComments; + } + return PrettyXml(xmlComments); + } - var element = XElement.Parse(xml); + /// + /// Make an Xml string pretty. + /// + /// Raw xml to make pretty. + /// A pretty (human readable) version of the input string. + private static string PrettyXml(string xml) + { + var stringBuilder = new StringBuilder(); - var settings = new XmlWriterSettings - { - OmitXmlDeclaration = true, - Indent = true, - NewLineOnAttributes = false - }; + var element = XElement.Parse(xml); - using (var xmlWriter = XmlWriter.Create(stringBuilder, settings)) - { - element.Save(xmlWriter); - } + var settings = new XmlWriterSettings + { + OmitXmlDeclaration = true, + Indent = true, + NewLineOnAttributes = false + }; - return stringBuilder.ToString(); + using (var xmlWriter = XmlWriter.Create(stringBuilder, settings)) + { + element.Save(xmlWriter); } + + return stringBuilder.ToString(); } } \ No newline at end of file diff --git a/SharpFM.Core/FileMakerClipExtensions.cs b/SharpFM.Core/FileMakerClipExtensions.cs index 05d9b65..e555f99 100644 --- a/SharpFM.Core/FileMakerClipExtensions.cs +++ b/SharpFM.Core/FileMakerClipExtensions.cs @@ -13,7 +13,7 @@ public static class FileMakerClipExtensions /// /// Create a class from scratch. /// - public static string CreateClass(this FileMakerClip _clip, FileMakerClip fieldProjectionLayout = null) + public static string CreateClass(this FileMakerClip _clip, FileMakerClip? fieldProjectionLayout = null) { if(_clip == null) { return string.Empty; } diff --git a/SharpFM.Core/FileMakerField.cs b/SharpFM.Core/FileMakerField.cs index 92dc6ee..4297c8e 100644 --- a/SharpFM.Core/FileMakerField.cs +++ b/SharpFM.Core/FileMakerField.cs @@ -8,13 +8,13 @@ public class FileMakerField { public int FileMakerFieldId { get; set; } - public string Name { get; set; } - - public string DataType { get; set; } + public string Name { get; set; } = null!; - public string FieldType { get; set; } + public string DataType { get; set; } = null!; - public string Comment { get; set; } + public string FieldType { get; set; } = null!; + + public string? Comment { get; set; } public bool NotEmpty { get; set; } diff --git a/SharpFM.Core/SharpFM.Core.csproj b/SharpFM.Core/SharpFM.Core.csproj index 05b9a7a..2e65c25 100644 --- a/SharpFM.Core/SharpFM.Core.csproj +++ b/SharpFM.Core/SharpFM.Core.csproj @@ -2,6 +2,8 @@ netstandard2.0 + latest + enable From 6e1b180e8de7e6d3f43161aaa08d07c5a44a780b Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Fri, 8 Sep 2023 14:17:10 -0500 Subject: [PATCH 03/12] initial AvaloniaEdit for rendering --- SharpFM.App/DocumentTextBindingBehavior.cs | 61 +++++++++++++++++++ SharpFM.App/MainWindow.axaml | 39 ++++++------ SharpFM.App/MainWindow.axaml.cs | 24 +++++++- SharpFM.App/SharpFM.App.csproj | 2 + SharpFM.App/ViewModels/MainWindowViewModel.cs | 22 ++++++- 5 files changed, 127 insertions(+), 21 deletions(-) create mode 100644 SharpFM.App/DocumentTextBindingBehavior.cs diff --git a/SharpFM.App/DocumentTextBindingBehavior.cs b/SharpFM.App/DocumentTextBindingBehavior.cs new file mode 100644 index 0000000..8a8f4d8 --- /dev/null +++ b/SharpFM.App/DocumentTextBindingBehavior.cs @@ -0,0 +1,61 @@ +using System; +using Avalonia; +using Avalonia.Xaml.Interactivity; +using AvaloniaEdit; +using AvaloniaEdit.Utils; + +namespace SharpFM.App.Behaviors; + +public class DocumentTextBindingBehavior : Behavior +{ + private TextEditor _textEditor = null!; + + public static readonly StyledProperty TextProperty = + AvaloniaProperty.Register(nameof(Text)); + + public string Text + { + get => GetValue(TextProperty); + set => SetValue(TextProperty, value); + } + + protected override void OnAttached() + { + base.OnAttached(); + + if (AssociatedObject is TextEditor textEditor) + { + _textEditor = textEditor; + _textEditor.TextChanged += TextChanged; + this.GetObservable(TextProperty).Subscribe(TextPropertyChanged); + } + } + + protected override void OnDetaching() + { + base.OnDetaching(); + + if (_textEditor != null) + { + _textEditor.TextChanged -= TextChanged; + } + } + + private void TextChanged(object sender, EventArgs eventArgs) + { + if (_textEditor != null && _textEditor.Document != null) + { + Text = _textEditor.Document.Text; + } + } + + private void TextPropertyChanged(string text) + { + if (_textEditor != null && _textEditor.Document != null && text != null) + { + var caretOffset = _textEditor.CaretOffset; + _textEditor.Document.Text = text; + //_textEditor.CaretOffset = caretOffset; + } + } +} \ No newline at end of file diff --git a/SharpFM.App/MainWindow.axaml b/SharpFM.App/MainWindow.axaml index fb41baa..13e2ca3 100644 --- a/SharpFM.App/MainWindow.axaml +++ b/SharpFM.App/MainWindow.axaml @@ -5,6 +5,8 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit" mc:Ignorable="d" d:DesignWidth="700" d:DesignHeight="500" + xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity" + xmlns:behaviors="clr-namespace:SharpFM.App.Behaviors;assembly=SharpFM.App" x:DataType="vm:MainWindowViewModel" x:Class="SharpFM.App.MainWindow" Title="SharpFM"> @@ -12,16 +14,18 @@ - - + - + + - - - + + + + + - - \ No newline at end of file diff --git a/SharpFM.App/MainWindow.axaml.cs b/SharpFM.App/MainWindow.axaml.cs index 6559166..2c1bc42 100644 --- a/SharpFM.App/MainWindow.axaml.cs +++ b/SharpFM.App/MainWindow.axaml.cs @@ -2,17 +2,37 @@ using System.Collections.ObjectModel; using Avalonia.Controls; using AvaloniaEdit; +using AvaloniaEdit.TextMate; using SharpFM.Core; +using TextMateSharp.Grammars; namespace SharpFM.App; public partial class MainWindow : Window { + private RegistryOptions _registryOptions; + private int _currentTheme = (int)ThemeName.DarkPlus; + private readonly TextMate.Installation _textMateInstallation; + private readonly TextEditor _textEditor; + public MainWindow() { InitializeComponent(); - var editor = this.FindControl("avaloniaEditor") ?? throw new Exception("no control"); - editor.Document = new AvaloniaEdit.Document.TextDocument("Hello world"); + _textEditor = this.FindControl("avaloniaEditor") ?? throw new Exception("no control"); + + _registryOptions = new RegistryOptions( + (ThemeName)_currentTheme); + + _textMateInstallation = _textEditor.InstallTextMate(_registryOptions); + Language xmlLang = _registryOptions.GetLanguageByExtension(".xml"); + _textMateInstallation.SetGrammar(_registryOptions.GetScopeByLanguageId(xmlLang.Id)); + } + + protected override void OnClosed(EventArgs e) + { + base.OnClosed(e); + + _textMateInstallation.Dispose(); } } \ No newline at end of file diff --git a/SharpFM.App/SharpFM.App.csproj b/SharpFM.App/SharpFM.App.csproj index a9f0115..440b501 100644 --- a/SharpFM.App/SharpFM.App.csproj +++ b/SharpFM.App/SharpFM.App.csproj @@ -16,6 +16,8 @@ + + diff --git a/SharpFM.App/ViewModels/MainWindowViewModel.cs b/SharpFM.App/ViewModels/MainWindowViewModel.cs index e0dfaf2..7c8faab 100644 --- a/SharpFM.App/ViewModels/MainWindowViewModel.cs +++ b/SharpFM.App/ViewModels/MainWindowViewModel.cs @@ -20,6 +20,20 @@ public MainWindowViewModel() [ObservableProperty] private string? _text; + [RelayCommand] + private void NewEmptyItem() + { + ErrorMessages?.Clear(); + try + { + Keys.Add(new FileMakerClip("New", "", Array.Empty())); + } + catch (Exception e) + { + ErrorMessages?.Add(e.Message); + } + } + [RelayCommand] private async Task PasteText(CancellationToken token) { @@ -62,7 +76,7 @@ private async Task DoGetClipboardDataAsync() var clip = new FileMakerClip("new-clip", format, dataObj); - if(clip is null) { continue; } + if (clip is null) { continue; } // don't bother adding a duplicate. For some reason entries were getting entered twice per clip // this is not the most efficient method to detect it, but it works well enough for now @@ -85,4 +99,10 @@ private async Task DoGetClipboardDataAsync() [ObservableProperty] private FileMakerClip? _selectedClip; + + public string SelectedXml + { + get => SelectedClip?.XmlData ?? ""; + set => SelectedClip!.XmlData = value; + } } \ No newline at end of file From 0480acf52927402494bff9047655acc26a140c41 Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Fri, 8 Sep 2023 14:19:05 -0500 Subject: [PATCH 04/12] don't set caret offset longer than text length --- SharpFM.App/DocumentTextBindingBehavior.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SharpFM.App/DocumentTextBindingBehavior.cs b/SharpFM.App/DocumentTextBindingBehavior.cs index 8a8f4d8..531769e 100644 --- a/SharpFM.App/DocumentTextBindingBehavior.cs +++ b/SharpFM.App/DocumentTextBindingBehavior.cs @@ -55,7 +55,10 @@ private void TextPropertyChanged(string text) { var caretOffset = _textEditor.CaretOffset; _textEditor.Document.Text = text; - //_textEditor.CaretOffset = caretOffset; + if (caretOffset <= text.Length) + { + _textEditor.CaretOffset = caretOffset; + } } } } \ No newline at end of file From 9269e93f452425cebf7e0ad87b85daa8902765b9 Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Fri, 8 Sep 2023 14:20:14 -0500 Subject: [PATCH 05/12] remove unused test prop --- SharpFM.App/ViewModels/MainWindowViewModel.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SharpFM.App/ViewModels/MainWindowViewModel.cs b/SharpFM.App/ViewModels/MainWindowViewModel.cs index 7c8faab..63b42c4 100644 --- a/SharpFM.App/ViewModels/MainWindowViewModel.cs +++ b/SharpFM.App/ViewModels/MainWindowViewModel.cs @@ -99,10 +99,4 @@ private async Task DoGetClipboardDataAsync() [ObservableProperty] private FileMakerClip? _selectedClip; - - public string SelectedXml - { - get => SelectedClip?.XmlData ?? ""; - set => SelectedClip!.XmlData = value; - } } \ No newline at end of file From c1f4c14b1e8b3bf1ad1e7aebaa9fcaf686dfce1a Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Fri, 8 Sep 2023 16:27:45 -0500 Subject: [PATCH 06/12] add copy command and button --- SharpFM.App/MainWindow.axaml | 4 +++ SharpFM.App/ViewModels/MainWindowViewModel.cs | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/SharpFM.App/MainWindow.axaml b/SharpFM.App/MainWindow.axaml index 13e2ca3..17ad270 100644 --- a/SharpFM.App/MainWindow.axaml +++ b/SharpFM.App/MainWindow.axaml @@ -25,6 +25,10 @@ + + Date: Mon, 11 Sep 2023 09:20:44 -0500 Subject: [PATCH 07/12] clean up all build warnings --- .vscode/tasks.json | 41 ++++++++++++++++++++++ SharpFM.App/DocumentTextBindingBehavior.cs | 2 +- SharpFM.Core/FileMakerClip.cs | 27 +++++++------- SharpFM.Core/SharpFM.Core.csproj | 2 +- 4 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1233377 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/SharpFM.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/SharpFM.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/SharpFM.sln" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/SharpFM.App/DocumentTextBindingBehavior.cs b/SharpFM.App/DocumentTextBindingBehavior.cs index 531769e..24a2315 100644 --- a/SharpFM.App/DocumentTextBindingBehavior.cs +++ b/SharpFM.App/DocumentTextBindingBehavior.cs @@ -41,7 +41,7 @@ protected override void OnDetaching() } } - private void TextChanged(object sender, EventArgs eventArgs) + private void TextChanged(object? sender, EventArgs eventArgs) { if (_textEditor != null && _textEditor.Document != null) { diff --git a/SharpFM.Core/FileMakerClip.cs b/SharpFM.Core/FileMakerClip.cs index ad0fb09..2b1248b 100644 --- a/SharpFM.Core/FileMakerClip.cs +++ b/SharpFM.Core/FileMakerClip.cs @@ -28,8 +28,6 @@ public class FileMakerClip /// Data containing the clip. public FileMakerClip(string name, string format, byte[] data) { - // pull in the name - Name = name; // load the format ClipboardFormat = format; // skip the first four bytes, as this is a length check @@ -40,11 +38,10 @@ public FileMakerClip(string name, string format, byte[] data) // try to show better "name" if possible var xdoc = XDocument.Load(new StringReader(XmlData)); - var containerName = xdoc.Element("fmxmlsnippet")?.Descendants().First()?.Attribute("name")?.Value; - if (!string.IsNullOrEmpty(containerName)) - { - Name = containerName; - } + var containerName = xdoc.Element("fmxmlsnippet")?.Descendants().First()?.Attribute("name")?.Value ?? ""; + + // set the name from the xml data if possible and fall back to constructor parameter + Name = containerName ?? name ?? "new-clip"; } /// @@ -55,7 +52,7 @@ public FileMakerClip(string name, string format, byte[] data) /// /// Name of Clip /// - public string Name { get; set; } + public string Name { get; set; } = string.Empty; /// /// Raw data that can be put back onto the Clipboard in FileMaker structure. @@ -94,19 +91,19 @@ public IEnumerable Fields .Elements("Field") .Select(x => new FileMakerField { - FileMakerFieldId = int.Parse(x.Attribute("id").Value), - Name = x.Attribute("name").Value, - DataType = x.Attribute("dataType").Value, - FieldType = x.Attribute("fieldType").Value, - NotEmpty = bool.Parse(x.Element("Validation")?.Element("NotEmpty")?.Attribute("value").Value ?? "false"), - Unique = bool.Parse(x.Element("Validation")?.Element("Unique")?.Attribute("value").Value ?? "false"), + FileMakerFieldId = int.Parse(x.Attribute("id")?.Value ?? ""), + Name = x.Attribute("name")?.Value ?? "", + DataType = x.Attribute("dataType")?.Value ?? "", + FieldType = x.Attribute("fieldType")?.Value ?? "", + NotEmpty = bool.Parse(x.Element("Validation")?.Element("NotEmpty")?.Attribute("value")?.Value ?? "false"), + Unique = bool.Parse(x.Element("Validation")?.Element("Unique")?.Attribute("value")?.Value ?? "false"), Comment = x.Element("Comment")?.Value, }); case "Layout": // on a layout we only have the field name (TABLE::FIELD) to go on, so we do that. return xdoc .Descendants("Object") - .Where(x => x.Attribute("type").Value == "Field") + .Where(x => x.Attribute("type")?.Value == "Field") .Descendants("FieldObj") .Elements("Name") .Select(x => new FileMakerField { Name = Regex.Split(x.Value, "::")[1] }); diff --git a/SharpFM.Core/SharpFM.Core.csproj b/SharpFM.Core/SharpFM.Core.csproj index 2e65c25..95d8a2a 100644 --- a/SharpFM.Core/SharpFM.Core.csproj +++ b/SharpFM.Core/SharpFM.Core.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + net6.0 latest enable From cc7518fd1894d1ac876e49a1b5efe53a350852cf Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Mon, 11 Sep 2023 12:27:20 -0500 Subject: [PATCH 08/12] switch data binding to custom type vs. dictionary --- SharpFM.App/MainWindow.axaml | 8 +++++--- SharpFM.Core/FileMakerClip.cs | 27 ++++++++++++++++--------- SharpFM.Core/FileMakerClipExtensions.cs | 8 ++++---- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/SharpFM.App/MainWindow.axaml b/SharpFM.App/MainWindow.axaml index 17ad270..b0b3f38 100644 --- a/SharpFM.App/MainWindow.axaml +++ b/SharpFM.App/MainWindow.axaml @@ -40,10 +40,12 @@ + SelectedValue="{Binding ClipboardFormat, Mode=TwoWay}" + SelectedValueBinding="{Binding KeyId}" + DisplayMemberBinding="{Binding DisplayName}" + > - + diff --git a/SharpFM.Core/FileMakerClip.cs b/SharpFM.Core/FileMakerClip.cs index 2b1248b..36f1f83 100644 --- a/SharpFM.Core/FileMakerClip.cs +++ b/SharpFM.Core/FileMakerClip.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Text; @@ -11,14 +12,20 @@ namespace SharpFM.Core; public class FileMakerClip { - public static Dictionary ClipTypes { get; set; } = new Dictionary - { - { "Mac-XMSS", "ScriptSteps" }, - { "Mac-XML2", "Layout" }, - { "Mac-XMTB", "Table" }, - { "Mac-XMFD", "Field" }, - { "Mac-XMSC", "Script" } - }; + public class ClipFormat + { + public string KeyId { get; set; } = string.Empty; + public string DisplayName { get; set; } = string.Empty; + } + + public static List ClipTypes { get; set; } = new List + { + new ClipFormat() { KeyId = "Mac-XMSS", DisplayName = "ScriptSteps" }, + new ClipFormat() { KeyId = "Mac-XML2", DisplayName = "Layout" }, + new ClipFormat() { KeyId = "Mac-XMTB", DisplayName = "Table" }, + new ClipFormat() { KeyId = "Mac-XMFD", DisplayName = "Field" }, + new ClipFormat() { KeyId = "Mac-XMSC", DisplayName = "Script" } + }; /// /// Constructor taking in the raw data byte array. @@ -83,7 +90,9 @@ public IEnumerable Fields { var xdoc = XDocument.Parse(XmlData); - switch (ClipTypes[ClipboardFormat]) + var clipType = ClipTypes.SingleOrDefault(ct => ct.KeyId == ClipboardFormat); + + switch (clipType.DisplayName) { case "Table": // When we have a table, we can get rich metadata from the clipboard data. return xdoc diff --git a/SharpFM.Core/FileMakerClipExtensions.cs b/SharpFM.Core/FileMakerClipExtensions.cs index e555f99..ceab080 100644 --- a/SharpFM.Core/FileMakerClipExtensions.cs +++ b/SharpFM.Core/FileMakerClipExtensions.cs @@ -15,10 +15,10 @@ public static class FileMakerClipExtensions /// public static string CreateClass(this FileMakerClip _clip, FileMakerClip? fieldProjectionLayout = null) { - if(_clip == null) { return string.Empty; } + if (_clip == null) { return string.Empty; } var fieldProjectionList = new List(); - if (fieldProjectionLayout != null && FileMakerClip.ClipTypes[fieldProjectionLayout.ClipboardFormat] == "Layout") + if (fieldProjectionLayout != null && FileMakerClip.ClipTypes.Single(ct => ct.KeyId == fieldProjectionLayout.ClipboardFormat).DisplayName == "Layout") { // a clip that is of type layout, only has name attribute (since the rest isn't available) // and we only need the name to skip it down below @@ -55,7 +55,7 @@ public static string CreateClass(this FileMakerClip _clip, IEnumerable f classDeclaration = classDeclaration.AddAttributeLists(SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(dataContractAttribute))); // add each field from the underling _clip as a public property with the data member attribute - List fieldsToBeAddedAsProperties = new List(_clip.Fields.Count()); + List fieldsToBeAddedAsProperties = new List(_clip.Fields.Count()); // include the field projection foreach (var field in _clip.Fields.Where(fmF => fieldProjectionList.Contains(fmF.Name))) { @@ -87,7 +87,7 @@ public static string CreateClass(this FileMakerClip _clip, IEnumerable f break; } - if(field.NotEmpty == false && propertyTypeCSharp != "string") + if (field.NotEmpty == false && propertyTypeCSharp != "string") { propertyTypeCSharp += "?"; } From 50e7c7bce8c196e2f6fa257f1e0010fa73dca4ee Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Mon, 11 Sep 2023 12:29:40 -0500 Subject: [PATCH 09/12] fix nullable --- SharpFM.Core/FileMakerClip.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharpFM.Core/FileMakerClip.cs b/SharpFM.Core/FileMakerClip.cs index 36f1f83..1f8f91c 100644 --- a/SharpFM.Core/FileMakerClip.cs +++ b/SharpFM.Core/FileMakerClip.cs @@ -92,7 +92,7 @@ public IEnumerable Fields var clipType = ClipTypes.SingleOrDefault(ct => ct.KeyId == ClipboardFormat); - switch (clipType.DisplayName) + switch (clipType?.DisplayName) { case "Table": // When we have a table, we can get rich metadata from the clipboard data. return xdoc From 040f7db69c5944632639b32c40bccd3265f685ad Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Mon, 11 Sep 2023 12:44:44 -0500 Subject: [PATCH 10/12] nuget package updates --- SharpFM.App/SharpFM.App.csproj | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/SharpFM.App/SharpFM.App.csproj b/SharpFM.App/SharpFM.App.csproj index 440b501..e6d702f 100644 --- a/SharpFM.App/SharpFM.App.csproj +++ b/SharpFM.App/SharpFM.App.csproj @@ -7,22 +7,28 @@ true app.manifest true + true + true + true + true + embedded + en - - + + - - + + - + - + From f9716065546fee4a26933d73c3ddd2d9fecb468a Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Mon, 11 Sep 2023 12:44:56 -0500 Subject: [PATCH 11/12] convert to menu vs column with buttons --- SharpFM.App/MainWindow.axaml | 40 ++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/SharpFM.App/MainWindow.axaml b/SharpFM.App/MainWindow.axaml index b0b3f38..a9894bc 100644 --- a/SharpFM.App/MainWindow.axaml +++ b/SharpFM.App/MainWindow.axaml @@ -10,28 +10,30 @@ x:DataType="vm:MainWindowViewModel" x:Class="SharpFM.App.MainWindow" Title="SharpFM"> - + + + + + + + + + + + + + + - - + - - - - - - - @@ -52,7 +54,7 @@ + + \ No newline at end of file From f440f1e0806eb3f614c09501c09da114b7b02d4f Mon Sep 17 00:00:00 2001 From: Nate Bross Date: Mon, 11 Sep 2023 15:47:10 -0500 Subject: [PATCH 12/12] include release artifacts --- .github/workflows/release-artifacts.yml | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/release-artifacts.yml diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml new file mode 100644 index 0000000..545e3fc --- /dev/null +++ b/.github/workflows/release-artifacts.yml @@ -0,0 +1,56 @@ +name: Publish-Release-To-Artifacts + +on: + release: + types: [published] + +jobs: + release: + name: Release + strategy: + matrix: + kind: ['linux', 'windows', 'macOS'] + include: + - kind: linux + os: ubuntu-latest + target: linux-x64 + - kind: windows + os: windows-latest + target: win-x64 + - kind: macOS + os: macos-latest + target: osx-x64 + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Setup dotnet + uses: actions/setup-dotnet@v3.2.0 + + - name: Build + shell: bash + run: | + tag=$(git describe --tags --abbrev=0) + release_name="SharpFM.App-$tag-${{ matrix.target }}" + + # Build everything + dotnet publish SharpFM.App/SharpFM.App.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" + + # Pack files + if [ "${{ matrix.target }}" == "win-x64" ]; then + # Pack to zip for Windows + 7z a -tzip "${release_name}.zip" "./${release_name}/*" + else + tar czvf "${release_name}.tar.gz" "$release_name" + fi + + # Delete output directory + rm -r "$release_name" + + - name: Publish + uses: softprops/action-gh-release@v1 + with: + files: "SharpFM.App*" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file