2016-03-20 09:01:04 +00:00
|
|
|
|
/*
|
|
|
|
|
_ _ _ ____ _ _____
|
|
|
|
|
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
|
|
|
|
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
|
|
|
|
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
|
|
|
|
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
|
|
|
|
|
2017-01-02 19:05:21 +00:00
|
|
|
|
Copyright 2015-2017 Łukasz "JustArchi" Domeradzki
|
2016-03-20 09:01:04 +00:00
|
|
|
|
Contact: JustArchi@JustArchi.net
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2016-04-12 16:42:16 +00:00
|
|
|
|
using System;
|
2016-03-20 09:01:04 +00:00
|
|
|
|
using System.Windows.Forms;
|
2016-03-20 04:27:30 +00:00
|
|
|
|
|
|
|
|
|
namespace ConfigGenerator {
|
|
|
|
|
internal sealed class EnhancedPropertyGrid : PropertyGrid {
|
2016-03-26 21:51:19 +00:00
|
|
|
|
private readonly ASFConfig ASFConfig;
|
2016-03-23 12:59:54 +00:00
|
|
|
|
|
2016-03-26 21:51:19 +00:00
|
|
|
|
internal EnhancedPropertyGrid(ASFConfig config) {
|
2017-03-14 11:20:29 +00:00
|
|
|
|
ASFConfig = config ?? throw new ArgumentNullException(nameof(config));
|
2016-03-20 07:29:27 +00:00
|
|
|
|
|
2016-03-20 05:41:12 +00:00
|
|
|
|
SelectedObject = config;
|
2016-03-20 04:27:30 +00:00
|
|
|
|
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
|
|
|
|
Dock = DockStyle.Fill;
|
|
|
|
|
HelpVisible = false;
|
|
|
|
|
ToolbarVisible = false;
|
|
|
|
|
}
|
2016-03-20 07:29:27 +00:00
|
|
|
|
|
2016-11-24 06:32:16 +00:00
|
|
|
|
protected override void OnGotFocus(EventArgs args) {
|
|
|
|
|
if (args == null) {
|
|
|
|
|
Logging.LogNullError(nameof(args));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnGotFocus(args);
|
2017-01-08 14:09:30 +00:00
|
|
|
|
ASFConfig.ValidateAndFix();
|
2016-11-24 06:32:16 +00:00
|
|
|
|
ASFConfig.Save();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-29 23:57:06 +00:00
|
|
|
|
protected override void OnPropertyValueChanged(PropertyValueChangedEventArgs args) {
|
|
|
|
|
if (args == null) {
|
|
|
|
|
Logging.LogNullError(nameof(args));
|
2016-03-20 09:01:04 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-29 23:57:06 +00:00
|
|
|
|
base.OnPropertyValueChanged(args);
|
2017-01-08 14:09:30 +00:00
|
|
|
|
ASFConfig.ValidateAndFix();
|
2016-03-20 07:29:27 +00:00
|
|
|
|
ASFConfig.Save();
|
2016-03-20 09:01:04 +00:00
|
|
|
|
|
|
|
|
|
BotConfig botConfig = ASFConfig as BotConfig;
|
2017-01-08 14:09:30 +00:00
|
|
|
|
if (botConfig?.Enabled != true) {
|
2016-05-13 04:32:42 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-08 14:09:30 +00:00
|
|
|
|
Tutorial.OnAction(Tutorial.EPhase.BotEnabled);
|
|
|
|
|
if (!string.IsNullOrEmpty(botConfig.SteamLogin) && !string.IsNullOrEmpty(botConfig.SteamPassword)) {
|
|
|
|
|
Tutorial.OnAction(Tutorial.EPhase.BotReady);
|
2016-03-20 09:01:04 +00:00
|
|
|
|
}
|
2016-03-20 07:29:27 +00:00
|
|
|
|
}
|
2016-03-20 04:27:30 +00:00
|
|
|
|
}
|
2016-11-24 06:32:16 +00:00
|
|
|
|
}
|