├── IHExt
├── App.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── app.manifest
│ └── Resources.resx
├── App.xaml
├── IHExt.csproj
├── MainWindow.xaml.cs
├── MainWindow.xaml
└── App.xaml.cs
├── ReadMe.txt
├── .gitattributes
├── IHExt.sln
└── .gitignore
/IHExt/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/IHExt/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ReadMe.txt:
--------------------------------------------------------------------------------
1 | IHExt is a program that is launched along side MGSV to act as an UI overlay when in Borderless Windowed mode in conjunction with the Infinite Heaven mod.
2 |
3 | I is currently installed alongside IH.
4 |
5 | It is however being superseded by IHHook (also bundled with IH).
6 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/IHExt/App.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/IHExt.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.23107.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IHExt", "IHExt\IHExt.csproj", "{FB2424C9-F46F-435A-B6AE-02B1AA32481C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {FB2424C9-F46F-435A-B6AE-02B1AA32481C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {FB2424C9-F46F-435A-B6AE-02B1AA32481C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {FB2424C9-F46F-435A-B6AE-02B1AA32481C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {FB2424C9-F46F-435A-B6AE-02B1AA32481C}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/IHExt/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace IHExt.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/IHExt/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("IHExt")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("IHExt")]
15 | [assembly: AssemblyCopyright("Copyright © 2017")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("0.1.6.0")]
55 | [assembly: AssemblyFileVersion("0.1.6.0")]
56 |
--------------------------------------------------------------------------------
/IHExt/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace IHExt.Properties {
12 |
13 |
14 | ///
15 | /// A strongly-typed resource class, for looking up localized strings, etc.
16 | ///
17 | // This class was auto-generated by the StronglyTypedResourceBuilder
18 | // class via a tool like ResGen or Visual Studio.
19 | // To add or remove a member, edit your .ResX file then rerun ResGen
20 | // with the /str option, or rebuild your VS project.
21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24 | internal class Resources {
25 |
26 | private static global::System.Resources.ResourceManager resourceMan;
27 |
28 | private static global::System.Globalization.CultureInfo resourceCulture;
29 |
30 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
31 | internal Resources() {
32 | }
33 |
34 | ///
35 | /// Returns the cached ResourceManager instance used by this class.
36 | ///
37 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
38 | internal static global::System.Resources.ResourceManager ResourceManager {
39 | get {
40 | if ((resourceMan == null)) {
41 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IHExt.Properties.Resources", typeof(Resources).Assembly);
42 | resourceMan = temp;
43 | }
44 | return resourceMan;
45 | }
46 | }
47 |
48 | ///
49 | /// Overrides the current thread's CurrentUICulture property for all
50 | /// resource lookups using this strongly typed resource class.
51 | ///
52 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
53 | internal static global::System.Globalization.CultureInfo Culture {
54 | get {
55 | return resourceCulture;
56 | }
57 | set {
58 | resourceCulture = value;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/IHExt/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
48 |
55 |
56 |
70 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | [Rr]eleases/
14 | x64/
15 | x86/
16 | build/
17 | bld/
18 | [Bb]in/
19 | [Oo]bj/
20 |
21 | # Roslyn cache directories
22 | *.ide/
23 |
24 | # MSTest test Results
25 | [Tt]est[Rr]esult*/
26 | [Bb]uild[Ll]og.*
27 |
28 | #NUNIT
29 | *.VisualState.xml
30 | TestResult.xml
31 |
32 | # Build Results of an ATL Project
33 | [Dd]ebugPS/
34 | [Rr]eleasePS/
35 | dlldata.c
36 |
37 | *_i.c
38 | *_p.c
39 | *_i.h
40 | *.ilk
41 | *.meta
42 | *.obj
43 | *.pch
44 | *.pdb
45 | *.pgc
46 | *.pgd
47 | *.rsp
48 | *.sbr
49 | *.tlb
50 | *.tli
51 | *.tlh
52 | *.tmp
53 | *.tmp_proj
54 | *.log
55 | *.vspscc
56 | *.vssscc
57 | .builds
58 | *.pidb
59 | *.svclog
60 | *.scc
61 |
62 | # Chutzpah Test files
63 | _Chutzpah*
64 |
65 | # Visual C++ cache files
66 | ipch/
67 | *.aps
68 | *.ncb
69 | *.opensdf
70 | *.sdf
71 | *.cachefile
72 |
73 | # Visual Studio profiler
74 | *.psess
75 | *.vsp
76 | *.vspx
77 |
78 | # TFS 2012 Local Workspace
79 | $tf/
80 |
81 | # Guidance Automation Toolkit
82 | *.gpState
83 |
84 | # ReSharper is a .NET coding add-in
85 | _ReSharper*/
86 | *.[Rr]e[Ss]harper
87 | *.DotSettings.user
88 |
89 | # JustCode is a .NET coding addin-in
90 | .JustCode
91 |
92 | # TeamCity is a build add-in
93 | _TeamCity*
94 |
95 | # DotCover is a Code Coverage Tool
96 | *.dotCover
97 |
98 | # NCrunch
99 | _NCrunch_*
100 | .*crunch*.local.xml
101 |
102 | # MightyMoose
103 | *.mm.*
104 | AutoTest.Net/
105 |
106 | # Web workbench (sass)
107 | .sass-cache/
108 |
109 | # Installshield output folder
110 | [Ee]xpress/
111 |
112 | # DocProject is a documentation generator add-in
113 | DocProject/buildhelp/
114 | DocProject/Help/*.HxT
115 | DocProject/Help/*.HxC
116 | DocProject/Help/*.hhc
117 | DocProject/Help/*.hhk
118 | DocProject/Help/*.hhp
119 | DocProject/Help/Html2
120 | DocProject/Help/html
121 |
122 | # Click-Once directory
123 | publish/
124 |
125 | # Publish Web Output
126 | *.[Pp]ublish.xml
127 | *.azurePubxml
128 | # TODO: Comment the next line if you want to checkin your web deploy settings
129 | # but database connection strings (with potential passwords) will be unencrypted
130 | *.pubxml
131 | *.publishproj
132 |
133 | # NuGet Packages
134 | *.nupkg
135 | # The packages folder can be ignored because of Package Restore
136 | **/packages/*
137 | # except build/, which is used as an MSBuild target.
138 | !**/packages/build/
139 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
140 | #!**/packages/repositories.config
141 |
142 | # Windows Azure Build Output
143 | csx/
144 | *.build.csdef
145 |
146 | # Windows Store app package directory
147 | AppPackages/
148 |
149 | # Others
150 | sql/
151 | *.Cache
152 | ClientBin/
153 | [Ss]tyle[Cc]op.*
154 | ~$*
155 | *~
156 | *.dbmdl
157 | *.dbproj.schemaview
158 | *.pfx
159 | *.publishsettings
160 | node_modules/
161 |
162 | # RIA/Silverlight projects
163 | Generated_Code/
164 |
165 | # Backup & report files from converting an old project file
166 | # to a newer Visual Studio version. Backup files are not needed,
167 | # because we have git ;-)
168 | _UpgradeReport_Files/
169 | Backup*/
170 | UpgradeLog*.XML
171 | UpgradeLog*.htm
172 |
173 | # SQL Server files
174 | *.mdf
175 | *.ldf
176 |
177 | # Business Intelligence projects
178 | *.rdl.data
179 | *.bim.layout
180 | *.bim_*.settings
181 |
182 | # Microsoft Fakes
183 | FakesAssemblies/
184 |
185 | .vs/
--------------------------------------------------------------------------------
/IHExt/IHExt.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {FB2424C9-F46F-435A-B6AE-02B1AA32481C}
8 | WinExe
9 | Properties
10 | IHExt
11 | IHExt
12 | v4.5
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 | LocalIntranet
38 |
39 |
40 | false
41 |
42 |
43 | Properties\app.manifest
44 |
45 |
46 | false
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 4.0
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | MSBuild:Compile
68 | Designer
69 |
70 |
71 | MSBuild:Compile
72 | Designer
73 |
74 |
75 | App.xaml
76 | Code
77 |
78 |
79 | MainWindow.xaml
80 | Code
81 |
82 |
83 |
84 |
85 | Code
86 |
87 |
88 | True
89 | True
90 | Resources.resx
91 |
92 |
93 | True
94 | Settings.settings
95 | True
96 |
97 |
98 | ResXFileCodeGenerator
99 | Resources.Designer.cs
100 |
101 |
102 |
103 | SettingsSingleFileGenerator
104 | Settings.Designer.cs
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
119 |
--------------------------------------------------------------------------------
/IHExt/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/IHExt/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Markup;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 |
18 | namespace IHExt {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : Window {
23 | public MainWindow() {
24 | InitializeComponent();
25 |
26 | Loaded += MainWindow_Loaded;
27 | }
28 |
29 | void MainWindow_Loaded(object sender, RoutedEventArgs e) {
30 | this.AnnounceLogBlockout.Visibility = Visibility.Hidden;
31 | this.runningLabel.Visibility = Visibility.Hidden;
32 | this.menuTitle.Visibility = Visibility.Hidden;
33 | this.menuItems.Visibility = Visibility.Hidden;
34 | this.menuTestWrap.Visibility = Visibility.Hidden;
35 | this.menuWrap.Visibility = Visibility.Hidden;
36 | this.menuHelp.Visibility = Visibility.Hidden;
37 | }
38 |
39 | void TextControl_OnEnter(object sender, KeyEventArgs e) {
40 | if (e.Key == Key.Enter) {
41 | TextBox textBox = (TextBox)sender;
42 |
43 | var app = (App)Application.Current;
44 | app.ToMgsvCmd("input|"+textBox.Name+"|"+textBox.Text);
45 |
46 | textBox.Text = String.Empty;
47 |
48 | e.Handled = true;
49 | }
50 | }
51 |
52 | public void ListBox_OnSelectionChanged(object sender, RoutedEventArgs e)
53 | {
54 | ListBox listBox = sender as ListBox;
55 | if (listBox != null)
56 | {
57 | ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
58 | int selectedIndex = listBox.SelectedIndex;
59 |
60 | if (selectedIndex == -1)//tex no item selected
61 | {
62 | } else {
63 | var app = (App)Application.Current;
64 | app.ToMgsvCmd("selected|" + listBox.Name + "|" + selectedIndex.ToString());
65 | }
66 |
67 | e.Handled = true;
68 | }
69 | }
70 |
71 | public void ListBox_OnDoubleClick(object sender, RoutedEventArgs e)
72 | {
73 | ListBox listBox = sender as ListBox;
74 | if (listBox != null)
75 | {
76 | ListBoxItem lbi = (listBox.SelectedItem as ListBoxItem);
77 | int selectedIndex = listBox.SelectedIndex;
78 |
79 | if (selectedIndex == -1)//tex no item selected
80 | {
81 | } else
82 | {
83 | var app = (App)Application.Current;
84 | app.ToMgsvCmd("activate|" + listBox.Name + "|" + selectedIndex.ToString());
85 | }
86 |
87 | e.Handled = true;
88 | }
89 | }
90 |
91 | public void ComboBox_OnSelectionChanged(object sender, RoutedEventArgs e)
92 | {
93 | ComboBox comboBox = sender as ComboBox;
94 | if (comboBox != null)
95 | {
96 | ComboBoxItem lbi = (comboBox.SelectedItem as ComboBoxItem);
97 | int selectedIndex = comboBox.SelectedIndex;
98 |
99 | if (selectedIndex == -1)//tex no item selected
100 | {
101 | } else
102 | {
103 | var app = (App)Application.Current;
104 | app.ToMgsvCmd("selectedcombo|" + comboBox.Name + "|" + selectedIndex.ToString());
105 | }
106 |
107 | e.Handled = true;
108 | }
109 | }
110 |
111 | private void minButton_Click(object sender, RoutedEventArgs e)
112 | {
113 | WindowState = WindowState.Minimized;
114 | }
115 |
116 | private void Window_Activated(object sender, EventArgs e)
117 | {
118 | minButton.Visibility = Visibility.Visible;
119 | }
120 |
121 | private void Window_Deactivated(object sender, EventArgs e)
122 | {
123 | minButton.Visibility = Visibility.Hidden;
124 | }
125 |
126 | private void Window_KeyDown(object sender, KeyEventArgs e)
127 | {
128 | if (e.Key == Key.Space)
129 | {
130 | var app = (App)Application.Current;
131 | app.ToMgsvCmd("togglemenu");
132 | }
133 | }
134 |
135 | private void ComboBox_KeyDown(object sender, KeyEventArgs e)
136 | {
137 | if (e.Key == Key.Enter)
138 | {
139 | ComboBox comboBox = (ComboBox)sender;
140 |
141 | var app = (App)Application.Current;
142 | app.ToMgsvCmd("input|" + comboBox.Name + "|" + comboBox.Text);
143 |
144 | comboBox.Text = String.Empty;
145 |
146 | e.Handled = true;
147 | }
148 | }
149 |
150 | private void ComboBox_LostFocus(object sender, RoutedEventArgs e)
151 | {
152 | //tex user edited combobox
153 | ComboBox comboBox = (ComboBox)sender;
154 | if (comboBox.SelectedIndex == -1)
155 | {
156 | var app = (App)Application.Current;
157 | app.ToMgsvCmd("comboboxtocurrent|" + comboBox.Name + "|" + comboBox.Text);
158 |
159 | e.Handled = true;
160 | }
161 | }
162 |
163 | private void OnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
164 | {
165 | var app = (App)Application.Current;
166 | app.ToMgsvCmd("GotKeyboardFocus|" + menuLine.Name);
167 | menuLine.SelectAll();
168 |
169 | e.Handled = true;
170 | }
171 |
172 | private void OnKeyDown(object sender, KeyEventArgs e)
173 | {
174 | if (e.Key == Key.Enter)
175 | {
176 | var app = (App)Application.Current;
177 | app.ToMgsvCmd("EnterText|" + menuLine.Name + "|" + menuLine.Text);
178 | }
179 | //DEBUGNOW e.Handled = true;
180 | }
181 |
182 | private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
183 | {
184 |
185 | TextBox textBox = sender as TextBox;
186 |
187 | if (textBox != null)
188 |
189 | {
190 | if (!textBox.IsKeyboardFocused)
191 | {
192 | textBox.Focus();
193 |
194 | textBox.SelectAll();
195 |
196 | e.Handled = true;
197 | }
198 | }
199 | }
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/IHExt/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
219 |
220 |
221 |
--------------------------------------------------------------------------------
/IHExt/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Configuration;
5 | using System.Data;
6 | using System.Diagnostics;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Runtime.InteropServices;
10 | using System.Text;
11 | using System.Threading;
12 | using System.Threading.Tasks;
13 | using System.Windows;
14 | using System.Windows.Automation;
15 | using System.Windows.Controls;
16 | using System.Windows.Input;
17 | using System.Windows.Markup;
18 |
19 | namespace IHExt
20 | {
21 | ///
22 | /// Interaction logic for App.xaml
23 | ///
24 | public partial class App : Application
25 | {
26 | private string gameDir;
27 | private string toExtFilePath;
28 | private string toMgsvFilePath;
29 |
30 | private SortedDictionary extToMgsvCmds = new SortedDictionary();//tex from ext to mgsv
31 |
32 | private Dictionary> commands = new Dictionary>();
33 |
34 | private int extToMgsvCurrent = 0;//tex current/max, last command to be written out
35 | private int extToMgsvComplete = 0;//tex min/confirmed executed by mgsv, only commands above this should be written out
36 | private int mgsvToExtComplete = 0;//tex min/confimed executed by ext
37 |
38 | private long extSession = 0;
39 | private long mgsvSession = 0;
40 |
41 | private Dictionary uiElements = new Dictionary();
42 |
43 | //
44 | ObservableCollection menuItems = new ObservableCollection();
45 |
46 | //tex combo
47 | ObservableCollection settingItems = new ObservableCollection();
48 |
49 | //
50 | Process gameProcess = null;
51 | AutomationFocusChangedEventHandler focusHandler = null;
52 |
53 | private void Application_Startup(object sender, StartupEventArgs e)
54 | {
55 | bool exitWithGame = true;//DEBUG
56 |
57 |
58 | string gameDir = @"C:\GamesSD\MGS_TPP";//DEBUG
59 | var args = e.Args;
60 | if (args.Count() > 0)
61 | {
62 | gameDir = args[0];
63 | }
64 |
65 | string modDir = "mod";
66 | if (args.Count() > 1)
67 | {
68 | modDir = args[1];
69 | }
70 |
71 |
72 | string gameProcessName = "mgsvtpp";
73 | if (args.Count() > 2)
74 | {
75 | gameProcessName = args[2];
76 | }
77 |
78 | this.gameDir = gameDir;
79 | this.toExtFilePath = $"{gameDir}/{modDir}/ih_toextcmds.txt";
80 | this.toMgsvFilePath = $"{gameDir}/{modDir}/ih_tomgsvcmds.txt";
81 |
82 | bool foundGameDir = true;
83 |
84 | if (!Directory.Exists(gameDir))
85 | {
86 | Console.WriteLine("Could not find gameDir: {0}", gameDir);
87 | Console.WriteLine("Please launch this program via Infinite Heaven.");
88 | Console.WriteLine("Or set the -gameDir arg correctly when launching this program.");
89 | foundGameDir = false;
90 | }
91 | if (!File.Exists(toExtFilePath))
92 | {
93 | Console.WriteLine("Could not find fromMGSVFile: {0}", toExtFilePath);
94 | foundGameDir = false;
95 | }
96 |
97 | if (!foundGameDir)
98 | {
99 | Application.Current.Shutdown();
100 | return;
101 | }
102 |
103 | if (exitWithGame)
104 | {
105 | Process[] gameProcesses = Process.GetProcessesByName(gameProcessName);
106 | if (gameProcesses.Count() == 0)
107 | {
108 | //DEBUGNOW message gameProcessName not started
109 | Application.Current.Shutdown();
110 | return;
111 | }
112 | if (gameProcesses.Count() > 1)
113 | {
114 | //DEBUGNOW WARN more than one gameProcessName process found
115 | Application.Current.Shutdown();
116 | return;
117 | }
118 |
119 | gameProcess = gameProcesses[0];
120 | gameProcess.EnableRaisingEvents = true;
121 | gameProcess.Exited += new EventHandler(OnGameProcess_Exited);
122 |
123 | //DEBUGNOW TODO: unstable
124 | //focusHandler = new AutomationFocusChangedEventHandler(OnFocusChange);
125 | //Automation.AddAutomationFocusChangedEventHandler(focusHandler);
126 | }
127 |
128 | commands.Add("Shutdown", ShutdownApp);
129 | commands.Add("TakeFocus", TakeFocus);
130 | commands.Add("CanvasVisible", CanvasVisible);
131 | commands.Add("CreateUiElement", CreateUiElement);
132 | commands.Add("RemoveUiElement", RemoveUiElement);
133 | commands.Add("SetContent", SetContent);
134 | commands.Add("SetText", SetText);
135 | commands.Add("SetTextBox", SetTextBox);
136 | commands.Add("UiElementVisible", UiElementVisible);
137 | commands.Add("ClearTable", ClearTable);
138 | commands.Add("AddToTable", AddToTable);
139 | commands.Add("UpdateTable", UpdateTable);
140 | commands.Add("SelectItem", SelectItem);
141 | commands.Add("ClearCombo", ClearCombo);
142 | commands.Add("AddToCombo", AddToCombo);
143 | commands.Add("SelectCombo", SelectCombo);
144 | commands.Add("SelectAllText", SelectAllText);
145 |
146 | FileSystemWatcher watcher = new FileSystemWatcher();
147 | watcher.Path = Path.GetDirectoryName(toExtFilePath);
148 | watcher.Filter = Path.GetFileName(toExtFilePath);
149 | watcher.NotifyFilter = NotifyFilters.LastWrite;
150 | watcher.EnableRaisingEvents = true;//tex < allow subscribed event -v- to actually fire
151 | watcher.Changed += new FileSystemEventHandler(OnToExtChanged);
152 |
153 | DateTime currentDate = DateTime.Now;
154 | extSession = currentDate.Ticks;
155 |
156 | WriteToMgsvFile();
157 |
158 | MainWindow mainWindow = new MainWindow();
159 | mainWindow.Show();
160 |
161 |
162 | AddTestMenuItems(); //DEBUG
163 |
164 | mainWindow.menuItems.ItemsSource = menuItems;
165 | mainWindow.menuSetting.ItemsSource = settingItems;
166 |
167 | SetFocusToGame();
168 |
169 | ToMgsvCmd("ready");
170 | }
171 |
172 | void AddTestMenuItems()
173 | {
174 | menuItems.Add("1:Menu line test: 1:SomeSetting");
175 | menuItems.Add("2:Menu line test longer: 14:Some much longer setting");
176 | menuItems.Add("3:Menu line test: 1:SomeSetting");
177 | menuItems.Add("4:Menu line test longer: 14:Some much longer setting");
178 | menuItems.Add("5:Menu line test: 1:SomeSetting");
179 | menuItems.Add("6:Menu line test longer: 14:Some much longer setting");
180 | menuItems.Add("7:Menu line test: 1:SomeSetting");
181 | menuItems.Add("8:Menu line test longer: 14:Some much longer setting");
182 | menuItems.Add("9:Menu line test: 1:SomeSetting");
183 | menuItems.Add("10:Menu line test longer: 14:Some much longer setting");
184 | menuItems.Add("11:Menu line test: 1:SomeSetting");
185 | menuItems.Add("12:Menu line test longer: 14:Some much longer setting");
186 | menuItems.Add("13:Menu line test: 1:SomeSetting");
187 | menuItems.Add("14:Menu line test longer: 14:Some much longer setting");
188 | menuItems.Add("1:Menu line test: 1:SomeSetting");
189 | menuItems.Add("2:Menu line test longer: 14:Some much longer setting");
190 | menuItems.Add("3:Menu line test: 1:SomeSetting");
191 | menuItems.Add("4:Menu line test longer: 14:Some much longer setting");
192 | menuItems.Add("5:Menu line test: 1:SomeSetting");
193 | menuItems.Add("6:Menu line test longer: 14:Some much longer setting");
194 | menuItems.Add("7:Menu line test: 1:SomeSetting");
195 | menuItems.Add("8:Menu line test longer: 14:Some much longer setting");
196 | menuItems.Add("9:Menu line test: 1:SomeSetting");
197 | menuItems.Add("10:Menu line test longer: 14:Some much longer setting");
198 | menuItems.Add("11:Menu line test: 1:SomeSetting");
199 | menuItems.Add("12:Menu line test longer: 14:Some much longer setting");
200 | menuItems.Add("13:Menu line test: 1:SomeSetting");
201 | menuItems.Add("14:Menu line test longer: 14:Some much longer setting");
202 |
203 | settingItems.Add("1. Setting test");
204 | settingItems.Add("2. Setting test with long text test");
205 | settingItems.Add("3. Setting test");
206 | settingItems.Add("4. Setting test");
207 | settingItems.Add("5. Setting test");
208 | settingItems.Add("6. Setting test");
209 | settingItems.Add("7. Setting test");
210 | settingItems.Add("8. Setting test");
211 | settingItems.Add("9. Setting test");
212 | settingItems.Add("1. Setting test");
213 | settingItems.Add("10. Setting test");
214 | settingItems.Add("11. Setting test");
215 | settingItems.Add("12. Setting test");
216 | }
217 |
218 | //tex on ih_toextcmds.txt changed
219 | private void OnToExtChanged(object source, FileSystemEventArgs e)
220 | {
221 | //Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
222 |
223 | using (FileStream fs = WaitForFile(this.toExtFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
224 | {
225 | using (StreamReader sr = new StreamReader(fs))
226 | {
227 | string line;
228 | int count = 0;
229 | while ((line = sr.ReadLine()) != null)
230 | {
231 | if (String.IsNullOrEmpty(line))
232 | {
233 | continue;
234 | }
235 |
236 | //Console.WriteLine(line);//DEBUG
237 | char[] delimiters = { '|' };
238 | string[] args = line.Split(delimiters);
239 | int messageId;
240 | if (Int32.TryParse(args[0], out messageId))
241 | {
242 | if (count == 0)
243 | { //tex messageid of first line is mgsv session id
244 | if (messageId != mgsvSession)
245 | {
246 | Console.WriteLine("MGSV session changed");
247 | mgsvSession = messageId;
248 | //DEBUGNOW mgsvToExtComplete = 0;//tex reset
249 | ToMgsvCmd("sessionchange");//tex a bit of nothing to get the extToMgsvComplete to update from the message, mgsv does likewise DEBUGNOW
250 | }
251 |
252 | int arg = 0;
253 | if (Int32.TryParse(args[2], out arg))
254 | {
255 | extToMgsvComplete = arg;
256 | }
257 | } else
258 | {
259 | if (messageId > mgsvToExtComplete)
260 | {//tex IHExt hasn't done this command yet yet
261 | string command = args[1];
262 |
263 | if (command == null)
264 | {
265 | //TODO: warn
266 | } else
267 | {
268 | if (!commands.ContainsKey(command))
269 | {
270 | //TODO: warn unrecognised command
271 | } else
272 | {
273 | commands[command](args);
274 | }
275 | }
276 |
277 | mgsvToExtComplete = messageId;
278 | }
279 | }
280 | }
281 | count++;
282 | }//end while readline
283 | }// end streamreader
284 | }//end waitforfile
285 |
286 | WriteToMgsvFile();
287 | }//end OnToExtChanged
288 |
289 | private void OnGameProcess_Exited(object sender, System.EventArgs e)
290 | {
291 | gameProcess = null;
292 | this.Dispatcher.Invoke(() => {
293 | Application.Current.Shutdown();
294 | });
295 | }
296 |
297 | private void OnAppActivated(object sender, EventArgs e)
298 | {
299 |
300 | }
301 |
302 | private void OnAppDeactivated(object sender, EventArgs e)
303 | {
304 | this.Dispatcher.Invoke(() => {
305 | var mainWindow = (MainWindow)Application.Current.MainWindow;
306 |
307 | //tex set focus away from menuLine else it will go into search everytime after the first time user selects it
308 | mainWindow.menuItems.Focus();
309 | });
310 | }
311 |
312 | private void OnFocusChange(object sender, AutomationFocusChangedEventArgs e)
313 | {
314 | this.Dispatcher.Invoke(() => {
315 | //tex automation like to throw up lots of exceptions for some reason
316 | try
317 | {
318 | var focusedHandle = new IntPtr(AutomationElement.FocusedElement.Current.NativeWindowHandle);
319 | var mainWindowHandle = Process.GetCurrentProcess().MainWindowHandle;
320 | if (gameProcess != null)
321 | {
322 | if (gameProcess.MainWindowHandle == focusedHandle)
323 | {
324 | //tex game has focus, so make sure ihext is
325 | //TODO: could probably get all fancy and match to window position and size, assuming (cant remember) mgstpp has a windowed not fullscreen mode
326 | if (Application.Current.MainWindow.WindowState == System.Windows.WindowState.Maximized)
327 | {
328 |
329 | } else
330 | {
331 | //Application.Current.MainWindow.WindowState = System.Windows.WindowState.Maximized;
332 | ShowWindow(mainWindowHandle, SW_SHOWNOACTIVATE);
333 | }
334 | } else
335 | {
336 | if (focusedHandle != mainWindowHandle)
337 | {
338 | //Application.Current.MainWindow.WindowState = System.Windows.WindowState.Minimized;
339 | }
340 | }
341 | }
342 | } catch (Exception ex)
343 | {
344 |
345 | }
346 | });
347 | }
348 |
349 | [DllImport("user32.dll")]
350 | internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);
351 |
352 | [DllImport("user32.dll")]
353 | internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
354 |
355 | private const int SW_SHOWNOACTIVATE = 4;
356 | private const int SW_SHOW = 5;
357 |
358 | private void SetFocusToGame()
359 | {
360 | if (gameProcess != null)
361 | {
362 | var hWnd = gameProcess.MainWindowHandle;
363 | SetForegroundWindow(hWnd);
364 | ShowWindow(hWnd, SW_SHOW);
365 | }
366 | }
367 |
368 | //to mgsv commands
369 | public void ToMgsvCmd(string cmd)
370 | {
371 | string message = extToMgsvCurrent.ToString() + "|" + cmd;
372 | extToMgsvCmds.Add(extToMgsvCurrent, message);
373 | extToMgsvCurrent++;
374 | WriteToMgsvFile();
375 | }
376 |
377 | private string GetSessionString()
378 | {
379 | return string.Format("{0}|cmdToExtCompletedIndex|{1}", extSession, mgsvToExtComplete);
380 | }
381 |
382 | private void WriteToMgsvFile()
383 | {
384 | //tex lua/mgsv io "r" opens in exclusive/lock, so have to wait
385 | using (FileStream fs = WaitForFile(this.toMgsvFilePath, FileMode.Truncate, FileAccess.Write, FileShare.None))
386 | {
387 | using (StreamWriter sw = new StreamWriter(fs))
388 | {
389 | string sessionString = GetSessionString();
390 | sw.WriteLine(sessionString); //tex always on first line, lets mgsv know what commands have been completed so it can cull them from the mgsvToExt file to stop if from infinitely growing
391 | //tex really from extToMgsvComplete+1, but the check for that uglifys code too much, and I can live with last complete command staying in the txt files
392 | for (int i = extToMgsvComplete; i < extToMgsvCurrent; i++)
393 | {
394 | string line = extToMgsvCmds[i];
395 | sw.WriteLine(line);
396 | }
397 | sw.Flush();
398 | }
399 | }
400 | }
401 |
402 | FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share)
403 | {
404 | for (int numTries = 0; numTries < 10; numTries++)
405 | {
406 | FileStream fs = null;
407 | try
408 | {
409 | fs = new FileStream(fullPath, mode, access, share);
410 | return fs;
411 | } catch (IOException)
412 | {
413 | if (fs != null)
414 | {
415 | fs.Dispose();
416 | }
417 | Thread.Sleep(50);
418 | }
419 | }
420 |
421 | return null;
422 | }
423 |
424 | private UIElement GetUiElement(string name)
425 | {
426 | UIElement uiElement;
427 | if (uiElements.TryGetValue(name, out uiElement))
428 | {
429 | return uiElement;
430 | }
431 | return null;
432 | }
433 |
434 | private UIElement FindCanvasElement(string name)
435 | {
436 | var mainWindow = (MainWindow)Application.Current.MainWindow;
437 | var canvas = mainWindow.MainCanvas;
438 |
439 | var element = canvas.FindName(name);
440 | UIElement uiElement = (UIElement)element;
441 | return uiElement;
442 | }
443 |
444 | //from mgsv commands
445 | private void ShutdownApp(string[] args)
446 | {
447 | this.Dispatcher.Invoke(() => {
448 | Application.Current.Shutdown();
449 | });
450 | }
451 |
452 | private void TakeFocus(string[] args)
453 | {
454 | this.Dispatcher.Invoke(() => {
455 | var mainWindow = (MainWindow)Application.Current.MainWindow;
456 | if (!mainWindow.IsActive)
457 | {
458 | mainWindow.Activate();
459 | } else
460 | {
461 | /*Process[] gameProcesses = Process.GetProcessesByName(gameProcessName);
462 | if (gameProcesses.Count() > 1)
463 | {
464 | }*/
465 | }
466 | });
467 | }
468 |
469 | //args bool visible
470 | private void CanvasVisible(string[] args)
471 | {
472 | if (args.Count() < 1 + 1)
473 | {
474 | return;
475 | }
476 |
477 | bool visible;
478 | if (!bool.TryParse(args[2], out visible))
479 | {
480 | return;
481 | }
482 |
483 | this.Dispatcher.Invoke(() => {
484 | var mainWindow = (MainWindow)Application.Current.MainWindow;
485 | var canvas = mainWindow.MainCanvas;
486 | if (visible == false)
487 | {
488 | canvas.Visibility = Visibility.Hidden;
489 | } else
490 | {
491 | canvas.Visibility = Visibility.Visible;
492 | }
493 | });
494 | }//end CanvasVisible
495 |
496 | //args string name, string xaml
497 | private void CreateUiElement(string[] args)
498 | {
499 | if (args.Count() < 1 + 2)
500 | {
501 | return;
502 | }
503 |
504 | string name = args[2];
505 | string xamlStr = args[3];
506 | if (name == null || xamlStr == null)
507 | {
508 | return;
509 | }
510 |
511 | UIElement existingElement;
512 | if (uiElements.TryGetValue(name, out existingElement))
513 | {
514 | //DEBUGNOW TODO WARN
515 | return;
516 | }
517 |
518 |
519 | this.Dispatcher.Invoke(() => {
520 | try
521 | {
522 | var uiElement = (FrameworkElement)XamlReader.Parse(xamlStr);
523 | uiElements[name] = uiElement;
524 |
525 | var mainWindow = (MainWindow)Application.Current.MainWindow;
526 | var canvas = mainWindow.MainCanvas;
527 | canvas.RegisterName(uiElement.Name, uiElement);
528 | canvas.Children.Add(uiElement);
529 | canvas.ApplyTemplate();
530 | } catch (Exception e)
531 | {
532 | //DEBUGNOW TODO WARN
533 | return;
534 | }
535 | });//end invoke
536 | }//end CreateUiElement
537 |
538 | //args string name
539 | private void RemoveUiElement(string[] args)
540 | {
541 | if (args.Count() < 1 + 1)
542 | {
543 | return;
544 | }
545 |
546 | string name = args[2];
547 | if (name == null)
548 | {
549 | return;
550 | }
551 |
552 | this.Dispatcher.Invoke(() => {
553 | var uiElement = FindCanvasElement(name);
554 | if (uiElement == null)
555 | {
556 | //DEBUGNOW WARN
557 | return;
558 | }
559 |
560 | uiElements.Remove(name);
561 |
562 | var mainWindow = (MainWindow)Application.Current.MainWindow;
563 | var canvas = mainWindow.MainCanvas;
564 |
565 | canvas.Children.Remove(uiElement);
566 | });
567 | }//end RemoveUiElement
568 |
569 | //args string name, string content
570 | private void SetContent(string[] args)
571 | {
572 | if (args.Count() < 1 + 2)
573 | {
574 | return;
575 | }
576 |
577 | string name = args[2];
578 | string content = args[3];
579 | if (name == null || content == null)
580 | {
581 | return;
582 | }
583 |
584 | //UIElement uiElement;
585 | //if (!uiElements.TryGetValue(name, out uiElement)) {
586 | // //DEBUGNOW TODO WARN
587 | // //return;
588 | //}
589 |
590 | this.Dispatcher.Invoke(() => {
591 | try
592 | {
593 | UIElement uiElement = FindCanvasElement(name);
594 | if (uiElement == null)
595 | {
596 | //DEBUGNOW TODO WARN
597 | return;
598 | }
599 |
600 | ContentControl contentControl = uiElement as ContentControl;
601 | if (contentControl == null)
602 | {
603 | //DEBUGNOW TODO WARN
604 | return;
605 | }
606 |
607 | contentControl.Content = content;
608 | } catch (Exception e)
609 | {
610 | //DEBUGNOW TODO WARN
611 | return;
612 | }
613 | });
614 | }//end SetContent
615 |
616 | //for textblock
617 | //args string name, string content
618 | private void SetText(string[] args)
619 | {
620 | if (args.Count() < 1 + 2)
621 | {
622 | return;
623 | }
624 |
625 | string name = args[2];
626 | string content = args[3];
627 | if (name == null || content == null)
628 | {
629 | return;
630 | }
631 |
632 | //UIElement uiElement;
633 | //if (!uiElements.TryGetValue(name, out uiElement)) {
634 | // //DEBUGNOW TODO WARN
635 | // //return;
636 | //}
637 |
638 | this.Dispatcher.Invoke(() => {
639 | try
640 | {
641 | UIElement uiElement = FindCanvasElement(name);
642 | if (uiElement == null)
643 | {
644 | //DEBUGNOW TODO WARN
645 | return;
646 | }
647 |
648 | TextBlock contentControl = uiElement as TextBlock;
649 | if (contentControl == null)
650 | {
651 | //DEBUGNOW TODO WARN
652 | return;
653 | }
654 |
655 | content.Replace(@"\n", "
");//DEBUGNOW
656 |
657 | contentControl.Text = content;
658 | } catch (Exception e)
659 | {
660 | //DEBUGNOW TODO WARN
661 | return;
662 | }
663 | });
664 | }//end SetText
665 |
666 | //for textbox
667 | //args string name, string content
668 | private void SetTextBox(string[] args)
669 | {
670 | if (args.Count() < 1 + 2)
671 | {
672 | return;
673 | }
674 |
675 | string name = args[2];
676 | string content = args[3];
677 | if (name == null || content == null)
678 | {
679 | return;
680 | }
681 |
682 | //UIElement uiElement;
683 | //if (!uiElements.TryGetValue(name, out uiElement)) {
684 | // //DEBUGNOW TODO WARN
685 | // //return;
686 | //}
687 |
688 | this.Dispatcher.Invoke(() => {
689 | try
690 | {
691 | UIElement uiElement = FindCanvasElement(name);
692 | if (uiElement == null)
693 | {
694 | //DEBUGNOW TODO WARN
695 | return;
696 | }
697 |
698 | TextBox contentControl = uiElement as TextBox;
699 | if (contentControl == null)
700 | {
701 | //DEBUGNOW TODO WARN
702 | return;
703 | }
704 |
705 | content.Replace(@"\n", "
");//DEBUGNOW
706 |
707 | contentControl.Text = content;
708 | } catch (Exception e)
709 | {
710 | //DEBUGNOW TODO WARN
711 | return;
712 | }
713 | });
714 | }//end SetText
715 |
716 | //args string name, bool visible
717 | private void UiElementVisible(string[] args)
718 | {
719 | if (args.Count() < 1 + 1)
720 | {
721 | return;
722 | }
723 |
724 | string name = args[2];
725 | if (name == null)
726 | {
727 | return;
728 | }
729 |
730 | int visible;
731 | if (!int.TryParse(args[3], out visible))
732 | {
733 | return;
734 | }
735 |
736 | this.Dispatcher.Invoke(() => {
737 | var uiElement = FindCanvasElement(name);
738 | if (uiElement == null)
739 | {
740 | return;
741 | }
742 |
743 | if (visible == 0)
744 | {
745 | uiElement.Visibility = Visibility.Hidden;
746 | } else
747 | {
748 | uiElement.Visibility = Visibility.Visible;
749 | }
750 | });
751 | }//end UiElementVisible
752 |
753 | private void ClearTable(string[] args)
754 | {
755 | if (args.Count() < 1 + 1)
756 | {
757 | return;
758 | }
759 | //TODO dict of tables
760 | string name = args[2];
761 | if (name == null)
762 | {
763 | return;
764 | }
765 | this.Dispatcher.Invoke(() => {
766 | var mainWindow = (MainWindow)Application.Current.MainWindow;
767 |
768 | mainWindow.menuItems.SelectionChanged -= mainWindow.ListBox_OnSelectionChanged; //KLUDGE SelectionChanged event fires on all changes, I just want on user changes
769 |
770 | menuItems.Clear();
771 |
772 | mainWindow.menuItems.SelectionChanged += mainWindow.ListBox_OnSelectionChanged;
773 | });
774 | }
775 |
776 | private void AddToTable(string[] args)
777 | {
778 | if (args.Count() < 1 + 2)
779 | {
780 | return;
781 | }
782 | //TODO dict of tables
783 | string name = args[2];
784 | if (name == null)
785 | {
786 | return;
787 | }
788 | string itemString = args[3];
789 | if (itemString == null)
790 | {
791 | return;
792 | }
793 | this.Dispatcher.Invoke(() => {
794 | var mainWindow = (MainWindow)Application.Current.MainWindow;
795 |
796 | mainWindow.menuItems.SelectionChanged -= mainWindow.ListBox_OnSelectionChanged; //KLUDGE SelectionChanged event fires on all changes, I just want on user changes
797 |
798 | menuItems.Add(itemString);
799 |
800 | mainWindow.menuItems.SelectionChanged += mainWindow.ListBox_OnSelectionChanged;
801 | });
802 | }
803 |
804 | private void UpdateTable(string[] args)
805 | {
806 | if (args.Count() < 1 + 2)
807 | {
808 | return;
809 | }
810 | //TODO dict of tables
811 | string name = args[2];
812 | if (name == null)
813 | {
814 | return;
815 | }
816 | int itemIndex;
817 | if (!int.TryParse(args[3], out itemIndex))
818 | {
819 | return;
820 | }
821 | string itemString = args[4];
822 | if (itemString == null)
823 | {
824 | return;
825 | }
826 | this.Dispatcher.Invoke(() => {
827 | if (itemIndex >= 0 && itemIndex < menuItems.Count())
828 | {
829 | menuItems[itemIndex] = itemString;
830 | }
831 | });
832 | }
833 |
834 | private void SelectItem(string[] args)
835 | {
836 | if (args.Count() < 1 + 2)
837 | {
838 | return;
839 | }
840 | //TODO dict of tables
841 | string name = args[2];
842 | if (name == null)
843 | {
844 | return;
845 | }
846 |
847 | int selectedIndex;
848 | if (!int.TryParse(args[3], out selectedIndex))
849 | {
850 | return;
851 | }
852 |
853 | this.Dispatcher.Invoke(() => {
854 | var mainWindow = (MainWindow)Application.Current.MainWindow;
855 |
856 | if (selectedIndex >= 0 && selectedIndex < menuItems.Count())
857 | {
858 | mainWindow.menuItems.SelectionChanged -= mainWindow.ListBox_OnSelectionChanged; //KLUDGE SelectionChanged event fires on all changes, I just want on user changes
859 |
860 | mainWindow.menuItems.SelectedIndex = selectedIndex;
861 | mainWindow.menuItems.ScrollIntoView(mainWindow.menuItems.Items[selectedIndex]);
862 |
863 | mainWindow.menuItems.SelectionChanged += mainWindow.ListBox_OnSelectionChanged;
864 | }
865 | });
866 | }
867 |
868 | private void ClearCombo(string[] args)
869 | {
870 | if (args.Count() < 1 + 1)
871 | {
872 | return;
873 | }
874 | //TODO dict of tables
875 | string name = args[2];
876 | if (name == null)
877 | {
878 | return;
879 | }
880 | this.Dispatcher.Invoke(() => {
881 | var mainWindow = (MainWindow)Application.Current.MainWindow;
882 |
883 | mainWindow.menuSetting.SelectionChanged -= mainWindow.ComboBox_OnSelectionChanged; //KLUDGE SelectionChanged event fires on all changes, I just want on user changes
884 |
885 | settingItems.Clear();
886 |
887 | mainWindow.menuSetting.SelectionChanged += mainWindow.ComboBox_OnSelectionChanged;
888 | });
889 | }
890 |
891 | private void AddToCombo(string[] args)
892 | {
893 | if (args.Count() < 1 + 2)
894 | {
895 | return;
896 | }
897 | //TODO dict of tables
898 | string name = args[2];
899 | if (name == null)
900 | {
901 | return;
902 | }
903 | string itemString = args[3];
904 | if (itemString == null)
905 | {
906 | return;
907 | }
908 | this.Dispatcher.Invoke(() => {
909 | var mainWindow = (MainWindow)Application.Current.MainWindow;
910 |
911 | mainWindow.menuSetting.SelectionChanged -= mainWindow.ComboBox_OnSelectionChanged; //KLUDGE SelectionChanged event fires on all changes, I just want on user changes
912 |
913 | settingItems.Add(itemString);
914 |
915 | mainWindow.menuSetting.SelectionChanged += mainWindow.ComboBox_OnSelectionChanged;
916 | });
917 | }
918 |
919 | private void SelectCombo(string[] args)
920 | {
921 | if (args.Count() < 1 + 2)
922 | {
923 | return;
924 | }
925 | //TODO dict of tables
926 | string name = args[2];
927 | if (name == null)
928 | {
929 | return;
930 | }
931 |
932 | int selectedIndex;
933 | if (!int.TryParse(args[3], out selectedIndex))
934 | {
935 | return;
936 | }
937 |
938 | this.Dispatcher.Invoke(() => {
939 | var mainWindow = (MainWindow)Application.Current.MainWindow;
940 |
941 | if (selectedIndex >= 0 && selectedIndex < menuItems.Count())
942 | {
943 | mainWindow.menuSetting.SelectionChanged -= mainWindow.ComboBox_OnSelectionChanged; //KLUDGE SelectionChanged event fires on all changes, I just want on user changes
944 |
945 | mainWindow.menuSetting.SelectedIndex = selectedIndex;
946 |
947 | mainWindow.menuSetting.SelectionChanged += mainWindow.ComboBox_OnSelectionChanged;
948 | }
949 | });
950 | }
951 |
952 | //for textbox
953 | //args string name
954 | private void SelectAllText(string[] args)
955 | {
956 | if (args.Count() < 1 + 1)
957 | {
958 | return;
959 | }
960 |
961 | string name = args[2];
962 | if (name == null )
963 | {
964 | return;
965 | }
966 |
967 | this.Dispatcher.Invoke(() => {
968 | try
969 | {
970 | UIElement uiElement = FindCanvasElement(name);
971 | if (uiElement == null)
972 | {
973 | //DEBUGNOW TODO WARN
974 | return;
975 | }
976 |
977 | TextBox contentControl = uiElement as TextBox;
978 | if (contentControl == null)
979 | {
980 | //DEBUGNOW TODO WARN
981 | return;
982 | }
983 |
984 | contentControl.SelectAll();
985 | } catch (Exception e)
986 | {
987 | //DEBUGNOW TODO WARN
988 | return;
989 | }
990 | });
991 | }//end SetText
992 |
993 | }//app class
994 | }//namespace
995 |
--------------------------------------------------------------------------------