Skip to content

Commit c636ac9

Browse files
committed
Релиз 1.3.2.0
1 parent 78a51d3 commit c636ac9

10 files changed

Lines changed: 225 additions & 38 deletions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System.ComponentModel;
2+
using System.Globalization;
3+
using System;
4+
using System.Runtime.CompilerServices;
5+
6+
namespace osfDesigner
7+
{
8+
public class MyDateTimeConverter : DateTimeConverter
9+
{
10+
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cultureInfo, object value, Type destinationType)
11+
{
12+
if (destinationType == typeof(string))
13+
{
14+
return value.ToString();
15+
}
16+
return base.ConvertTo(context, cultureInfo, RuntimeHelpers.GetObjectValue(value), destinationType);
17+
}
18+
19+
public new static string ConvertToString(object value)
20+
{
21+
return value.ToString();
22+
}
23+
24+
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
25+
{
26+
if (destinationType.Equals(typeof(string)))
27+
{
28+
return true;
29+
}
30+
return base.CanConvertTo(context, destinationType);
31+
}
32+
33+
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo cultureInfo, object value)
34+
{
35+
if (!(value is string))
36+
{
37+
return base.ConvertFrom(context, cultureInfo, RuntimeHelpers.GetObjectValue(value));
38+
}
39+
return value.ToString();
40+
}
41+
42+
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
43+
{
44+
return true;
45+
}
46+
47+
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
48+
{
49+
return false;
50+
}
51+
}
52+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Drawing.Design;
4+
using System.Windows.Forms.Design;
5+
using System.Windows.Forms;
6+
7+
namespace osfDesigner
8+
{
9+
public class MyDateTimeEditor : UITypeEditor
10+
{
11+
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
12+
{
13+
IWindowsFormsEditorService wfes = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
14+
15+
if (wfes != null)
16+
{
17+
frmDateTime _frmDateTime = new frmDateTime();
18+
19+
_frmDateTime.DateTimePicker1.Value = System.DateTime.Parse((string)value);
20+
_frmDateTime._wfes = wfes;
21+
_frmDateTime.Show();
22+
23+
wfes.DropDownControl(_frmDateTime);
24+
DateTime _DateTime1 = _frmDateTime.DateTimePicker1.Value;
25+
value = _DateTime1.ToString();
26+
}
27+
return value;
28+
}
29+
30+
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
31+
{
32+
return UITypeEditorEditStyle.DropDown;
33+
}
34+
}
35+
36+
public class frmDateTime : System.Windows.Forms.Form
37+
{
38+
public System.Windows.Forms.DateTimePicker DateTimePicker1;
39+
private Container components = null;
40+
public IWindowsFormsEditorService _wfes;
41+
42+
public frmDateTime()
43+
{
44+
DateTimePicker1 = new System.Windows.Forms.DateTimePicker();
45+
DateTimePicker1.Parent = this;
46+
DateTimePicker1.Dock = System.Windows.Forms.DockStyle.Fill;
47+
DateTimePicker1.CustomFormat = "dd.MM.yyyy";
48+
DateTimePicker1.Format = DateTimePickerFormat.Custom;
49+
50+
ControlBox = false;
51+
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
52+
MaximizeBox = false;
53+
MinimizeBox = false;
54+
Name = "frmDateTime";
55+
ShowInTaskbar = false;
56+
Closed += frmDateTime_Closed;
57+
Width = 200;
58+
Height = DateTimePicker1.Height;
59+
60+
TopLevel = false;
61+
}
62+
63+
private void frmDateTime_Closed(object sender, EventArgs e)
64+
{
65+
_wfes.CloseDropDown();
66+
}
67+
68+
protected override void Dispose(bool disposing)
69+
{
70+
if (disposing)
71+
{
72+
if (components != null)
73+
{
74+
components.Dispose();
75+
}
76+
}
77+
base.Dispose(disposing);
78+
}
79+
}
80+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.ComponentModel;
2+
using System.Globalization;
3+
using System.Runtime.CompilerServices;
4+
using System;
5+
using ScriptEngine.Machine;
6+
7+
namespace osfDesigner
8+
{
9+
public class MyDecimalConverter : DecimalConverter
10+
{
11+
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cultureInfo, object value, Type destinationType)
12+
{
13+
if (destinationType == typeof(string))
14+
{
15+
string str1 = ((IValue)value).AsNumber().ToString();
16+
return str1;
17+
}
18+
return base.ConvertTo(context, cultureInfo, RuntimeHelpers.GetObjectValue(value), destinationType);
19+
}
20+
21+
public new static string ConvertToString(object value)
22+
{
23+
string str1 = value.ToString();
24+
return str1;
25+
}
26+
27+
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
28+
{
29+
if (destinationType.Equals(typeof(string)))
30+
{
31+
return true;
32+
}
33+
return base.CanConvertTo(context, destinationType);
34+
}
35+
36+
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo cultureInfo, object value)
37+
{
38+
if (!(value is string))
39+
{
40+
return base.ConvertFrom(context, cultureInfo, RuntimeHelpers.GetObjectValue(value));
41+
}
42+
IValue rez = ValueFactory.Create(Decimal.Parse((string)value));
43+
return rez;
44+
}
45+
46+
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
47+
{
48+
return true;
49+
}
50+
51+
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
52+
{
53+
return false;
54+
}
55+
}
56+
}

OneScriptFormsDesigner/OneScriptFormsDesigner/OneScriptFormsDesigner.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@
233233
<Compile Include="MyDataGridViewComboBoxCollectionEditor.cs" />
234234
<Compile Include="MyDateCollectionConverter.cs" />
235235
<Compile Include="MyDateCollectionEditor.cs" />
236+
<Compile Include="MyDateTimeConverter.cs" />
237+
<Compile Include="MyDateTimeEditor.cs" />
238+
<Compile Include="MyDecimalConverter.cs" />
236239
<Compile Include="MyDockEditor.cs" />
237240
<Compile Include="MyFontConverter.cs" />
238241
<Compile Include="MyFormMenuConverter.cs" />

OneScriptFormsDesigner/OneScriptFormsDesigner/PropValueConverter.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ public static void SetPropValue(
6565
{
6666
if (parent.GetType() == typeof(osfDesigner.TabPage))
6767
{
68-
control.Parent = ((dynamic)parent).OriginalObj;
68+
try
69+
{
70+
((osfDesigner.TabPage)parent).OriginalObj.Controls.Add(control);
71+
}
72+
catch
73+
{
74+
control.Parent = parent;
75+
}
6976
}
7077
else
7178
{
7279
control.Parent = parent;
73-
}
80+
}
7481
}
7582
}
7683
if (valProp == "Истина")
@@ -780,14 +787,7 @@ public static void SetPropValue(
780787
}
781788
else
782789
{
783-
if (control.GetType() == typeof(osfDesigner.FolderBrowserDialog))
784-
{
785-
valProp = valProp.Remove(0, 1);
786-
}
787-
else
788-
{
789-
valProp = valProp.Replace("\u0022", "");
790-
}
790+
valProp = valProp.Replace("\u0022", "");
791791
}
792792
try
793793
{

OneScriptFormsDesigner/OneScriptFormsDesigner/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// Можно задать все значения или принять номера сборки и редакции по умолчанию
3333
// используя "*", как показано ниже:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.3.1.0")]
36-
[assembly: AssemblyFileVersion("1.3.1.0")]
35+
[assembly: AssemblyVersion("1.3.2.0")]
36+
[assembly: AssemblyFileVersion("1.3.2.0")]

OneScriptFormsDesigner/OneScriptFormsDesigner/pDesignerMainForm.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4036,12 +4036,11 @@ public void LoadForm_Click(string fileName, bool choosingName, string sFile = nu
40364036
string itemText = OneScriptFormsDesigner.ParseBetween(strPropertyValue, "(", ",").Replace("\u0022", "");
40374037
string itemValue = OneScriptFormsDesigner.ParseBetween(strPropertyValue, ",", ")");
40384038
osfDesigner.ListItemComboBox ListItemComboBox1 = new ListItemComboBox();
4039-
////////ListItemComboBox1.Text = itemText; // Кажется это не нужно.
4039+
ListItemComboBox1.Text = itemText;
40404040

4041-
if (itemValue.Contains("\u0022")) // Тип Строка.
4041+
if (itemValue.StartsWith("\u0022") && itemValue.EndsWith("\u0022")) // Тип Строка.
40424042
{
4043-
itemValue = itemValue.Remove(0, 1);
4044-
itemValue = itemValue.Remove(itemValue.Length - 1, 1);
4043+
itemValue = itemValue.Replace("\u0022", "");
40454044
ListItemComboBox1.Value = itemValue;
40464045
ListItemComboBox1.ValueType = DataType.Строка;
40474046
}
@@ -4099,13 +4098,12 @@ public void LoadForm_Click(string fileName, bool choosingName, string sFile = nu
40994098
else // Обрабатываем как свойство поля выбора.
41004099
{
41014100
string displayName = OneScriptFormsDesigner.ParseBetween(strCurrent, componentName + ".", "=");
4102-
string strPropertyValue = OneScriptFormsDesigner.ParseBetween(strCurrent, "=", null);
4103-
strPropertyValue = strPropertyValue.Remove(strPropertyValue.Length - 1, 1);
4101+
string strPropertyValue = OneScriptFormsDesigner.ParseBetween(strCurrent, "=", ";");
41044102
string parentName = OneScriptFormsDesigner.ParseBetween(ComponentBlok, componentName + @".Родитель=", @";");
41054103
Control parent = (Control)dictObjects[parentName];
41064104
PropValueConverter.SetPropValue(control, displayName, strPropertyValue, NameObjectOneScriptForms, parent);
41074105
}
4108-
}
4106+
}
41094107
else if (componentName.Contains("СеткаДанных"))
41104108
{
41114109
string controlName = ((osfDesigner.DataGrid)control).Name;
708 KB
Binary file not shown.

docs/down.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
<p style="margin-left: 40px;">Первая версия дизайнера вышла 23 февраля 2022 г. с номером 1.0.0.0</p>
2525

2626
<hr style="border-color: lightgray; margin-left: 40px; margin-right: 40px;">
27-
<p style="margin-left: 40px;">Версия 1.3.1.0 -&nbsp;<a href="OneScriptFormsDesigner1_3_1_0.zip"><big><span style="font-weight: bold;"><button>скачать</button></span></big></a></p>
27+
<p style="margin-left: 40px;">Версия 1.3.2.0 -&nbsp;<a href="OneScriptFormsDesigner1_3_2_0.zip"><big><span style="font-weight: bold;"><button>скачать</button></span></big></a></p>
2828
<div style="margin-left: 40px;"></div>
2929
<div style="margin-left: 40px;">
3030
<details><summary>Описание</summary>
3131
<div style="margin-left: 40px;">
32-
- Исправлена ошибка для объекта ПолеВыбора (ComboBox) при восстановления из сохраненного файла сценария.
32+
- Исправлена ошибка для объекта ПолеВыбора (ComboBox) при восстановления из сохраненного файла сценария
3333
</div>
3434
</details>
3535
</div>

tests/ГенерацияДизайнераCS.os

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9566,12 +9566,19 @@
95669566
| {
95679567
| if (parent.GetType() == typeof(osfDesigner.TabPage))
95689568
| {
9569-
| control.Parent = ((dynamic)parent).OriginalObj;
9569+
| try
9570+
| {
9571+
| ((osfDesigner.TabPage)parent).OriginalObj.Controls.Add(control);
9572+
| }
9573+
| catch
9574+
| {
9575+
| control.Parent = parent;
9576+
| }
95709577
| }
95719578
| else
95729579
| {
95739580
| control.Parent = parent;
9574-
| }
9581+
| }
95759582
| }
95769583
| }
95779584
| if (valProp == ""Истина"")
@@ -10281,14 +10288,7 @@
1028110288
| }
1028210289
| else
1028310290
| {
10284-
| if (control.GetType() == typeof(osfDesigner.FolderBrowserDialog))
10285-
| {
10286-
| valProp = valProp.Remove(0, 1);
10287-
| }
10288-
| else
10289-
| {
10290-
| valProp = valProp.Replace(""\u0022"", """");
10291-
| }
10291+
| valProp = valProp.Replace(""\u0022"", """");
1029210292
| }
1029310293
| try
1029410294
| {
@@ -19319,12 +19319,11 @@
1931919319
| string itemText = OneScriptFormsDesigner.ParseBetween(strPropertyValue, ""("", "","").Replace(""\u0022"", """");
1932019320
| string itemValue = OneScriptFormsDesigner.ParseBetween(strPropertyValue, "","", "")"");
1932119321
| osfDesigner.ListItemComboBox ListItemComboBox1 = new ListItemComboBox();
19322-
| ////////ListItemComboBox1.Text = itemText; // Кажется это не нужно.
19322+
| ListItemComboBox1.Text = itemText;
1932319323
|
19324-
| if (itemValue.Contains(""\u0022"")) // Тип Строка.
19324+
| if (itemValue.StartsWith(""\u0022"") && itemValue.EndsWith(""\u0022"")) // Тип Строка.
1932519325
| {
19326-
| itemValue = itemValue.Remove(0, 1);
19327-
| itemValue = itemValue.Remove(itemValue.Length - 1, 1);
19326+
| itemValue = itemValue.Replace(""\u0022"", """");
1932819327
| ListItemComboBox1.Value = itemValue;
1932919328
| ListItemComboBox1.ValueType = DataType.Строка;
1933019329
| }
@@ -19382,13 +19381,12 @@
1938219381
| else // Обрабатываем как свойство поля выбора.
1938319382
| {
1938419383
| string displayName = OneScriptFormsDesigner.ParseBetween(strCurrent, componentName + ""."", ""="");
19385-
| string strPropertyValue = OneScriptFormsDesigner.ParseBetween(strCurrent, ""="", null);
19386-
| strPropertyValue = strPropertyValue.Remove(strPropertyValue.Length - 1, 1);
19384+
| string strPropertyValue = OneScriptFormsDesigner.ParseBetween(strCurrent, ""="", "";"");
1938719385
| string parentName = OneScriptFormsDesigner.ParseBetween(ComponentBlok, componentName + @"".Родитель="", @"";"");
1938819386
| Control parent = (Control)dictObjects[parentName];
1938919387
| PropValueConverter.SetPropValue(control, displayName, strPropertyValue, NameObjectOneScriptForms, parent);
1939019388
| }
19391-
| }
19389+
| }
1939219390
| else if (componentName.Contains(""СеткаДанных""))
1939319391
| {
1939419392
| string controlName = ((osfDesigner.DataGrid)control).Name;

0 commit comments

Comments
 (0)