Исправили поведение при несохраненых настройках

This commit is contained in:
klavirshik 2024-10-18 19:04:30 +02:00
parent d78d2f58d7
commit c1d1a7c3d8
20 changed files with 147 additions and 87 deletions

Binary file not shown.

View File

@ -22,8 +22,10 @@ namespace Remontor
internal partial class BarSessionControl : UserControl
{
public delegate bool HideBars(BarShow state);
public HideBars hideTab;
public HideBars hideTabWords;
public HideBars hideTabHistory;
public HideBars hideTabSetting;
private BarShow barShow = BarShow.HideBar;
public List<BarButtonControl> buttons;
@ -56,14 +58,33 @@ namespace Remontor
public void ShowBarSet(BarShow barShow)
{
if (barShow == BarShow.ShowSetting)
{
hideTabSetting(barShow);
ShowSetting.BackColor = SystemColors.ActiveCaption;
}
else
{
if (hideTabSetting(barShow))
{
barShow = BarShow.ShowSetting;
ShowSetting.BackColor = SystemColors.ActiveCaption;
}
else
{
ShowSetting.BackColor = SystemColors.Control;
}
}
if (barShow == BarShow.ShowWords) { ShowWords.BackColor = SystemColors.ActiveCaption; }
else { ShowWords.BackColor = SystemColors.Control; }
if (barShow == BarShow.ShowHistory) { ShowBar.BackColor = SystemColors.ActiveCaption; }
else { ShowBar.BackColor = SystemColors.Control; }
if (barShow == BarShow.ShowSetting) { ShowSetting.BackColor = SystemColors.ActiveCaption; }
else { ShowSetting.BackColor = SystemColors.Control; }
hideTab(barShow);
hideTabWords(barShow);
hideTabHistory(barShow);
}
private void ShowBar_Click(object sender, EventArgs e)

View File

@ -1,4 +1,5 @@
using System;
using Remontor.Setting;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@ -57,17 +58,27 @@ namespace Remontor.Connector
public void ConnectSCCM(Control panel)
{
View = new Panel();
View.Dock = DockStyle.Fill;
panel.Controls.Add(View);
ModeMonitor = new OneMon();
//Proc = Process.Start(@"CmRcViewer.exe", Comp.GetNetNameStr());
Proc = Process.Start("notepad");
//Thread.Sleep(500); // Allow the process to open it's window
Proc.WaitForInputIdle();
SetParent(Proc.MainWindowHandle, View.Handle);
SetWindowLong(Proc.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
ModeMonitor.Resize(Proc, View);
try {
View = new Panel();
View.Dock = DockStyle.Fill;
panel.Controls.Add(View);
ModeMonitor = new OneMon();
//Proc = Process.Start(@"CmRcViewer.exe", Comp.GetNetNameStr());
Proc = Process.Start(SGlobalSetting.settingApp.pathApp);
//Thread.Sleep(500); // Allow the process to open it's window
Proc.WaitForInputIdle();
SetParent(Proc.MainWindowHandle, View.Handle);
SetWindowLong(Proc.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
ModeMonitor.Resize(Proc, View);
}
catch (Exception) {
MessageBox.Show("Не верно заданно придложение для подключения.");
ModeMonitor = new OffMon();
SConnector.Panel.Controls.Remove(View);
return;
}
}
public void Activ(bool act)
@ -119,10 +130,10 @@ namespace Remontor.Connector
public void Delete()
{
Proc.CloseMainWindow();
if (Proc != null) Proc.CloseMainWindow();
ModeMonitor = new OffMon();
SConnector.Panel.Controls.Remove(View);
Proc.Close();
if (Proc != null) Proc.Close();
}
}
}

View File

@ -18,7 +18,7 @@ namespace Remontor.Connector
public static event UpdateModeMon UpdateMode;
private static List<Connect> Connects = new List<Connect>();
public static Control Panel;
public static Form FormMain;
public static Form1 FormMain;
public static Connect ActionConnect = null;
public static void NewConnect(IComp comp)
{

View File

@ -31,6 +31,7 @@
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label2 = new System.Windows.Forms.Label();
this.HistoryPanel = new System.Windows.Forms.FlowLayoutPanel();
this.BtSave = new System.Windows.Forms.Button();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
@ -39,23 +40,25 @@
this.tableLayoutPanel1.BackColor = System.Drawing.SystemColors.Control;
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.BtSave, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.HistoryPanel, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(330, 781);
this.tableLayoutPanel1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 3);
this.label2.Margin = new System.Windows.Forms.Padding(3);
this.label2.Location = new System.Drawing.Point(6, 3);
this.label2.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(120, 13);
this.label2.TabIndex = 3;
@ -68,9 +71,19 @@
this.HistoryPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.HistoryPanel.Location = new System.Drawing.Point(3, 23);
this.HistoryPanel.Name = "HistoryPanel";
this.HistoryPanel.Size = new System.Drawing.Size(324, 755);
this.HistoryPanel.Size = new System.Drawing.Size(324, 725);
this.HistoryPanel.TabIndex = 6;
//
// BtSave
//
this.BtSave.Location = new System.Drawing.Point(3, 754);
this.BtSave.Name = "BtSave";
this.BtSave.Size = new System.Drawing.Size(323, 24);
this.BtSave.TabIndex = 7;
this.BtSave.Text = "Очистить историю";
this.BtSave.UseVisualStyleBackColor = true;
this.BtSave.Click += new System.EventHandler(this.BtSave_Click);
//
// FlowContainer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -91,5 +104,6 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.FlowLayoutPanel HistoryPanel;
private System.Windows.Forms.Button BtSave;
}
}

View File

@ -46,6 +46,9 @@ namespace Remontor
}
private void BtSave_Click(object sender, EventArgs e)
{
HistoryList.Clear();
}
}
}

View File

@ -29,26 +29,49 @@
private void InitializeComponent()
{
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.BtSave = new System.Windows.Forms.Button();
this.BtAbout = new System.Windows.Forms.Button();
this.settingWordsControl1 = new Remontor.Setting.SettingWordsControl();
this.settingSCCMControl1 = new Remontor.Setting.SettingSCCMControl();
this.settingAppControl1 = new Remontor.Setting.settingAppControl();
this.BtSave = new System.Windows.Forms.Button();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flowLayoutPanel1.Controls.Add(this.settingWordsControl1);
this.flowLayoutPanel1.Controls.Add(this.settingSCCMControl1);
this.flowLayoutPanel1.Controls.Add(this.settingAppControl1);
this.flowLayoutPanel1.Controls.Add(this.BtSave);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(330, 781);
this.flowLayoutPanel1.Size = new System.Drawing.Size(330, 592);
this.flowLayoutPanel1.TabIndex = 0;
//
// BtSave
//
this.BtSave.Location = new System.Drawing.Point(3, 432);
this.BtSave.Name = "BtSave";
this.BtSave.Size = new System.Drawing.Size(323, 28);
this.BtSave.TabIndex = 3;
this.BtSave.Text = "Сохранить";
this.BtSave.UseVisualStyleBackColor = true;
this.BtSave.Click += new System.EventHandler(this.BtSave_Click);
//
// BtAbout
//
this.BtAbout.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.BtAbout.Location = new System.Drawing.Point(3, 598);
this.BtAbout.Name = "BtAbout";
this.BtAbout.Size = new System.Drawing.Size(324, 28);
this.BtAbout.TabIndex = 4;
this.BtAbout.Text = "О программе";
this.BtAbout.UseVisualStyleBackColor = true;
//
// settingWordsControl1
//
this.settingWordsControl1.Location = new System.Drawing.Point(3, 3);
@ -70,23 +93,14 @@
this.settingAppControl1.Size = new System.Drawing.Size(325, 130);
this.settingAppControl1.TabIndex = 2;
//
// BtSave
//
this.BtSave.Location = new System.Drawing.Point(3, 432);
this.BtSave.Name = "BtSave";
this.BtSave.Size = new System.Drawing.Size(323, 28);
this.BtSave.TabIndex = 3;
this.BtSave.Text = "Сохранить";
this.BtSave.UseVisualStyleBackColor = true;
this.BtSave.Click += new System.EventHandler(this.BtSave_Click);
//
// FlowConteinerSetting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.flowLayoutPanel1);
this.Controls.Add(this.BtAbout);
this.Name = "FlowConteinerSetting";
this.Size = new System.Drawing.Size(330, 781);
this.Size = new System.Drawing.Size(330, 629);
this.flowLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
@ -99,5 +113,6 @@
private Setting.SettingSCCMControl settingSCCMControl1;
private Setting.settingAppControl settingAppControl1;
private System.Windows.Forms.Button BtSave;
private System.Windows.Forms.Button BtAbout;
}
}

View File

@ -1,4 +1,5 @@
using Remontor.Setting;
using Remontor.Connector;
using Remontor.Setting;
using Remontor.Words;
using System;
using System.Collections.Generic;
@ -33,6 +34,7 @@ namespace Remontor
{
if (barShow == BarShow.ShowSetting)
{
unSave = false;
this.Visible = true;
settingAppControl1.UpdateSetting();
settingSCCMControl1.UpdateSetting();
@ -40,44 +42,34 @@ namespace Remontor
}
else
{
this.Visible = false;
if (!SConnector.FormMain.CloseOn && !unSave && (settingAppControl1.edited() ||
settingSCCMControl1.edited() ||
settingWordsControl1.edited()))
{
unSave = true;
DialogResult result = MessageBox.Show("Изменения не сохраненны. Продолжить?", "Изменения не сохраненны.", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
switch (result)
{
case DialogResult.Cancel:
this.Visible = true;
unSave = false;
break;
case DialogResult.OK:
this.Visible = false;
unSave = true;
break;
}
}
else
{
this.Visible = false;
}
}
return this.Visible;
}
//private bool NotSave()
//{
// if (tabControl1.SelectedIndex == 3)
// {
// if (!unSave)
// {
// unSave = true;
// UpdateSetting();
// }
// }
// else
// {
// if (unSave && (settingAppControl1.edited() ||
// settingSCCMControl1.edited() ||
// settingWordsControl1.edited()))
// {
// DialogResult result = MessageBox.Show("Изменения не сохраненны. Продолжить?", "Изменения не сохраненны.", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
// switch (result)
// {
// case DialogResult.Cancel:
// tabControl1.SelectedIndex = 3;
// break;
// case DialogResult.OK:
// unSave = false;
// break;
// }
// }
// }
//}
private void BtSave_Click(object sender, EventArgs e)
{
Save();

View File

@ -43,6 +43,8 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel3.Controls.Add(this.flowConteinerSetting1);
this.panel3.Controls.Add(this.flowContainerWords1);
this.panel3.Controls.Add(this.flowContainer1);
this.panel3.Controls.Add(this.label1);
this.panel3.Location = new System.Drawing.Point(0, 25);
this.panel3.Name = "panel3";
@ -66,7 +68,7 @@
this.flowContainerWords1.BackColor = System.Drawing.SystemColors.Control;
this.flowContainerWords1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.flowContainerWords1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flowContainerWords1.Location = new System.Drawing.Point(763, 40);
this.flowContainerWords1.Location = new System.Drawing.Point(764, 18);
this.flowContainerWords1.Margin = new System.Windows.Forms.Padding(0);
this.flowContainerWords1.Name = "flowContainerWords1";
this.flowContainerWords1.Size = new System.Drawing.Size(330, 678);
@ -90,7 +92,7 @@
this.flowContainer1.BackColor = System.Drawing.Color.Transparent;
this.flowContainer1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.flowContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flowContainer1.Location = new System.Drawing.Point(763, 40);
this.flowContainer1.Location = new System.Drawing.Point(764, 18);
this.flowContainer1.Name = "flowContainer1";
this.flowContainer1.Size = new System.Drawing.Size(330, 675);
this.flowContainer1.TabIndex = 1;
@ -100,9 +102,10 @@
//
this.flowConteinerSetting1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.flowConteinerSetting1.Location = new System.Drawing.Point(764, 15);
this.flowConteinerSetting1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flowConteinerSetting1.Location = new System.Drawing.Point(764, 18);
this.flowConteinerSetting1.Name = "flowConteinerSetting1";
this.flowConteinerSetting1.Size = new System.Drawing.Size(330, 781);
this.flowConteinerSetting1.Size = new System.Drawing.Size(330, 675);
this.flowConteinerSetting1.TabIndex = 1;
this.flowConteinerSetting1.Visible = false;
//
@ -111,9 +114,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1094, 718);
this.Controls.Add(this.flowContainerWords1);
this.Controls.Add(this.barSessionControl1);
this.Controls.Add(this.flowContainer1);
this.Controls.Add(this.panel3);
this.Name = "Form1";
this.Text = "Form1";

View File

@ -39,15 +39,16 @@ namespace Remontor
Process p1;
Process p;
public bool CloseOn = false;
public Form1()
{
SGlobalSetting.LoadSetting();
//WordsList.MainCategory = SGlobalSetting.LoadWords();
InitializeComponent();
barSessionControl1.hideTab += flowContainer1.HideBar;
barSessionControl1.hideTab += flowContainerWords1.HideBar;
barSessionControl1.hideTab += flowConteinerSetting1.HideBar;
barSessionControl1.hideTabHistory += flowContainer1.HideBar;
barSessionControl1.hideTabWords += flowContainerWords1.HideBar;
barSessionControl1.hideTabSetting += flowConteinerSetting1.HideBar;
SConnector.Panel = this.panel3;
SConnector.FormMain = this;
@ -60,7 +61,7 @@ namespace Remontor
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
@ -111,7 +112,7 @@ namespace Remontor
if ((m.Msg == 0x210 && m.WParam.ToInt32() == 513) || m.Msg == 0x201)
{
Point clickPoint = this.PointToClient(Cursor.Position);
if (!flowContainer1.Bounds.Contains(clickPoint))
if (!flowContainerWords1.Bounds.Contains(clickPoint))
{
barSessionControl1.ShowBarSet(BarShow.HideBar);
}
@ -139,6 +140,7 @@ namespace Remontor
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
CloseOn = true;
flowContainerWords1.Save();
SGlobalSetting.SaveSettig();

View File

@ -38,6 +38,7 @@ namespace Remontor.History
static public void Clear()
{
Hitem.Clear();
Update(Hitem);
}
static public void ClearFirst()

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.