|
I'm sure, with a bit of lateral thinking, you could make a game out of form filling.
|
|
|
|
|
Way off topic; I'll try. If I succeed, it will become a new article.
..I just never looked at it that way; it is a game, not a form. Input is input, regardless where it comes from?
Thank you for making my day
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
What is a "game"?
I was a Windows Form evangelist because WPF didn't have a data grid at the time. Then WPF ... I now use UWP because it gets me in the Store, for one thing. (But now any exe can be added to the Store.)
My game consists mostly of moving rectangles around and measuring angles and distances. "Gettysburg!" It's under "Books and References" so I don't pay the "game premium".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Codice Fictor wrote: Simply put, how would I research and find the solution for these types of problems:
The general problem is that you need to map one value to another value.
The specifics of the values for each is not really relevant. The process however, obviously, is.
Being a bit more specific to your problem you want to map a 'string' (text) to something.
I can't actually tell what you want to map to. But lets say, for example, that it is enum.
Then there are two choices.
1. The string must match the name of the enum exactly. You can get by without case sensitivity but otherwise it must be the same.
2. You MUST provide code that maps from the string to the enum.
Note that there are NO other choices. Pick one.
Lets say you want to pick 1. Then you cannot name a key 'A Key' because a space is not something that can appear in a enum name. You can google for how to convert from string to enum and back again.
Or if you pick 2. There are various ways to do this. But one way actually ends up looking like solution 1. So for example you would have a table that looks like what I posted below. You would read it then match the first value. Then use the second value to create an enum (like I said similar to 1.)
'A Key', 'KeyA'
'B Key', 'KeyB'
'= Key', 'KeyEquals'
Or you could just create a switch
switch(keyValue)
{
case "A Key": return KeyValue.KeyA;
case "B Key": return KeyVAlue.KeyB;
There are variations on this.
|
|
|
|
|
It’s getting clear now…. Because of my background and my only experience with C# is working with objects, refs and pointers created and generated at run time, I was lost on setting up a reference (linking them) in my code with the instantiation of a pre-existing object dragged onto the Form. Every help link is about creating an object with your definitions and manipulating what you created not syntax/methodology on decoding what you didn’t create.
Thank you………..
And I understand Class and SubClass structure but not how to maneuver around in it in C#.
Now that I can pass my Form Control around in my code I’m not sure the buzz words to comprehend this problem (abbreviated):
private void ManuplateButtons(Control InputButton)
{
InputButton.Text = // Good
Button12.FlatStyle = // Good (pre-instantiated on Form)
InputButton.FlatStyle = // CS1061 'type' does not contain a definition …………
Button FlatStyle is available but Control FlatStyle is not in the list of parameters. So now I need to learn how to dig into the object reference(Control InputButton) to find how FlatStyle is referenced inside of the object reference (Control InputButton).
Is it Control.InputButton.A.B.C nope, so I need to learn how to navigate into the object reference (Control InputButton) and query where FlatStyle is stored or discover what else I can do with an object I didn’t create. I imagine this is not an across the board answer because of the many things you could put/reference in an object.
Timeout; I was composing this when I just read jschell’s post. I believe I have caught up to your post.
In reference to above and #1: I usually depend on the Visual Studio dropdown list and look up the details of the options available until I find the parameter/function that I need or the research of the p/f leads me to an answer. The available button12.X where x = Flatstyle, Flatstyle is in the list but in the case of reference(Control InputButton). Flatstyle is not in the list so I must find it……….. methodology unknown to me ‘yet’.
“…..convert from string to enum” but I need to find the enum def for reference(Control InputButton).Flatstyle before I can convert my string to the relevant enum. I understand the cross correlation between 1 & 2 of jschell’s post.
What are the key search phrases of OOP for the methodology and implementation of how discover what is enumerated in an object that is not shown in the dropdown list, because if “string must match the name of the enum exactly” I need to find the exact spelling or the relevant reference. I know a blind search is going to give me a 1000 hits on how to enumerate a string not how to dig into an unknown enumerated string to find out what is inside, so any tips or pointer links on how to decode an existing object would be useful. Once I learn what is available inside I can learn how to manipulate it…………
Thanks……….
|
|
|
|
|
Button, inherits from ButtonBase, which inherits from Control.
FlatStyle is defined in ButtonBase. At a minimum, you need to "cast" Control to ButtonBase to access that property.
As a side note, ButtonBase is an "abstract" class: you can't actually create ButtonBase except via a class that inherits it (like Button, CheckBox, and RadioButton; or your own "custom" button).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Thank You Jerry,
ButtonBase BUTTONx = this.Controls.["button1"];
I tried that before and ButtonBase doesn't associate with the string name. I get error CS1001 at the '['.
This doesn't work either ButtonBase.Button BUTTONx = this.Controls.["button1"];
|
|
|
|
|
Codice Fictor wrote: this.Controls.["button1"];
I seriously doubt that there is any situation in which the period before the bracket would ever be valid.
|
|
|
|
|
I posted about "is" and "as" already in this thread; which would have answered your question.
The other aspect related to "is" and "as" is "boxing"; but that is generally used for "value types".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
i want code to search in data grid view by date that the same date in date time picker tool in the same form ?
|
|
|
|
|
And what help are you expecting from this forum?
|
|
|
|
|
OK, the only code you get is the code YOU write.
Don't search the grid. Search the DataSource your grid should be bound to. If you're not already doing this, you're making it much more difficult on yourself.
|
|
|
|
|
Dave Kreskowiak wrote: OK, the only code you get is the code YOU write. When people ask for code, we now can direct them toward ChatGPT. *evil grin*
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I waded through all the detritus that the AI powered search engines tossed at me, and managed to narrow things down with:
Quote: C# search for date gridview from date picker
https://stackoverflow.com/questions/62045173/filter-datagridview-from-datepicker
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Probably the most relevant part of that link is the following very important advice when searching for time values.
"Because, no matter how hard I tried, I could not remove the time from the datetime value . . . I decided to use a greater than date and less than date."
Although it is still incorrect.
That is exclusive on both ends. One needs to to exclusive on one end and inclusive on the other.
|
|
|
|
|
1 namespace ATAS.Indicators.Technical;
2
3 using ATAS.Indicators.Drawing;
4 using OFT.Localization;
5 using OFT.Rendering.Context;
6 using OFT.Rendering.Settings;
7 using OFT.Rendering.Tools;
8 using System;
9 using System.ComponentModel;
10 using System.ComponentModel.DataAnnotations;
11 using System.Drawing;
12 using System.Runtime.Intrinsics.X86;
13 using Color = System.Drawing.Color;
14
15 [DisplayName("Candle X")]
16 public class CandleStatist : Indicator
17 {
18 #region Nested types
19
20 public enum LabelLocations
21 {
22 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.AboveCandle))]
23 Top,
24
25 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.BelowCandle))]
26 Bottom,
27
28 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.ByCandleDirection))]
29 CandleDirection
30 }
31
32 #endregion
33
34 #region Fields
35
36 private readonly PenSettings _bgPen = new() { Color = DefaultColors.Gray.Convert() };
37 private readonly BrushSettings _bgBrush = new();
38 private readonly RenderStringFormat _format = new()
39
40
41 {
42 Alignment = StringAlignment.Center,
43 LineAlignment = StringAlignment.Center,
44 };
45 private int _backGroundTransparency = 8;
46
47
48
49 const int X = 100;
50 public double uhv;
51 private double av;
52 public double r;
53 public double ar;
54 public double uwrb;
55 public double wrb;
56 public double u3;
57 public double m3;
58 public double l20d;
59
60
61 #endregion
62
63 #region Properties
64
65 #region Settings
66
67 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.LabelLocation), GroupName = nameof(Strings.Settings))]
68 public LabelLocations LabelLocation { get; set; } = LabelLocations.Top;
69
70 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.ShowVolume), GroupName = nameof(Strings.Settings))]
71 public bool ShowVolume { get; set; } = true;
72
73 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.ShowDelta), GroupName = nameof(Strings.Settings))]
74 public bool ShowDelta { get; set; } = true;
75
76 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.ClustersMode), GroupName = nameof(Strings.Settings))]
77 public bool ClusterModeOnly { get; set; }
78
79 #endregion
80
81 #region Visualization
82
83 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.Volume), GroupName = nameof(Strings.Visualization))]
84 public Color VolumeColor { get; set; } = DefaultColors.White;
85
86 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.PositiveDelta), GroupName = nameof(Strings.Visualization))]
87 public Color PositiveDeltaColor { get; set; } = Color.Green;
88
89 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.NegativeDelta), GroupName = nameof(Strings.Visualization))]
90 public Color NegativeDeltaColor { get; set; } = Color.Red;
91
92 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.BackGround), GroupName = nameof(Strings.Visualization))]
93 public Color BackGroundColor
94 {
95 get => _bgPen.Color.Convert();
96 set
97 {
98 _bgPen.Color = value.Convert();
99 _bgBrush.StartColor = GetColorTransparency(value, BackGroundTransparency).Convert();
100 }
101 }
102
103 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.HideBackGround), GroupName = nameof(Strings.Visualization))]
104 public bool HideBackGround { get; set; } = true;
105
106 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.Font), GroupName = nameof(Strings.Visualization))]
107 public FontSetting FontSetting { get; set; } = new("Times New Roman", 6);
108
109 [Range(0, int.MaxValue)]
110 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.Offset), GroupName = nameof(Strings.Visualization))]
111 public int Offset { get; set; } = 10;
112
113 [Range(1, 10)]
114 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.BorderWidth), GroupName = nameof(Strings.Visualization))]
115 public int BorderWidth
116 {
117 get => _bgPen.Width;
118 set => _bgPen.Width = value;
119 }
120
121 [Range(0, 10)]
122 [Display(ResourceType = typeof(Strings), Name = nameof(Strings.Transparency), GroupName = nameof(Strings.Visualization))]
123 public int BackGroundTransparency
124 {
125 get => _backGroundTransparency;
126 set
127 {
128 _backGroundTransparency = value;
129 _bgBrush.StartColor = GetColorTransparency(BackGroundColor, BackGroundTransparency).Convert();
130 }
131 }
132
133 #endregion
134
135 #endregion
136
137 #region ctor
138
139 public CandleStatist() : base(true)
140 {
141 DenyToChangePanel = true;
142 DataSeries[0].IsHidden = true;
143 ((ValueDataSeries)DataSeries[0]).ShowZeroValue = false;
144
145 EnableCustomDrawing = true;
146 SubscribeToDrawingEvents(DrawingLayouts.Final);
147
148 _bgPen.Color = BackGroundColor.Convert();
149 _bgBrush.StartColor = GetColorTransparency(BackGroundColor, _backGroundTransparency).Convert();
150 }
151
152 #endregion
153
154 #region Protected methods
155
156 protected override void OnCalculate(int bar, decimal value)
157 {
158 }
159
160 protected override void OnRender(RenderContext context, DrawingLayouts layout)
161 {
162 if (ChartInfo == null)
163 return;
164
165 if (ClusterModeOnly && ChartInfo.ChartVisualMode != ChartVisualModes.Clusters)
166 return;
167
168 DrawLabels(context);
169 }
170
171 #endregion
172
173 #region Private methods
174
175 public readonly SMA _sma = new SMA() { Period = X };
176 public readonly HighestX _highestX = new HighestX() ;
177 public readonly LowestX _lowestX = new LowestX();
178
179 private void DrawLabels(RenderContext context)
180 {
181 if (!(ShowDelta || ShowVolume))
182 return;
183
184 for (int bar = FirstVisibleBarNumber; bar <= LastVisibleBarNumber; bar++)
185 {
186 var candle = GetCandle(bar);
187
188
189 var av = _sma.Calculate(X, (candle.Volume));
190 var uhv = ((candle.Volume) > (2 * av));
191 var r = (candle.High - candle.Low);
192 var ar = _sma.Calculate(X, (candle.High - candle.Low));
193
194
195 var uwrb = (r > (2m * ar));
196 var wrb = (r > (1.33m * ar)) && (r < (2m * ar));
197 var u3 = (candle.Close > (candle.High - (r / 3)));
198 var m3 = (candle.Close > (candle.High - (r / 3))) && (candle.Close > (candle.Low + (r / 3)));
199
200 var prevCandle = GetCandle(bar-1);
201 var l20d = (candle.Low) < prevCandle.(_lowestX.Calculate(20, candle.Low));
202
203
204
205
206 var delta = candle.Delta;
207 var volumeStr = ChartInfo.TryGetMinimizedVolumeString(candle.Volume);
208 var deltaStr = ChartInfo.TryGetMinimizedVolumeString(delta);
209
210 var shiftBetweenStr = (int)(FontSetting.RenderObject.Size / 100 * 20);
211 var shift = 2;
212
213 var volumeSize = new Size();
214 var deltaSize = new Size();
215
216 if (ShowVolume)
217 volumeSize = context.MeasureString(volumeStr, FontSetting.RenderObject);
218
219 if (ShowDelta)
220 deltaSize = context.MeasureString(deltaStr, FontSetting.RenderObject);
221
222 var h = volumeSize.Height + deltaSize.Height + shift * 2 + shiftBetweenStr;
223 var y = (int)GetStartY(candle, h);
224 var w = Math.Max(volumeSize.Width, deltaSize.Width) + shift * 2;
225 w = GetTrueWidth(w);
226 var x = ChartInfo.GetXByBar(bar) + (int)((ChartInfo.PriceChartContainer.BarsWidth - w) / 2);
227
228 var rectangle = new Rectangle(x, y, w, h);
229
230 if (!HideBackGround)
231 context.DrawFillRectangle(_bgPen.RenderObject, _bgBrush.RenderObject.StartColor, rectangle);
232
233 if (ShowVolume)
234 {
235 y += shift;
236 var rec = new Rectangle(x, y, w, volumeSize.Height);
237 context.DrawString(volumeStr, FontSetting.RenderObject, VolumeColor, rec, _format);
238 }
239
240 if (ShowDelta)
241 {
242 y += volumeSize.Height > 0 ? volumeSize.Height + shiftBetweenStr : shift;
243 var rec = new Rectangle(x, y, w, deltaSize.Height);
244 var color = delta < 0 ? NegativeDeltaColor : PositiveDeltaColor;
245 context.DrawString(deltaStr, FontSetting.RenderObject, color, rec, _format);
246 }
247 }
248 }
249
250 private string GetTrueString(decimal value)
251 {
252 var absValue = Math.Abs(value);
253
254 if ((int)absValue < absValue)
255 return value.ToString().TrimEnd('0');
256
257 return value.ToString();
258 }
259
260 private int GetTrueWidth(int width)
261 {
262 return Math.Min(width, (int)ChartInfo.PriceChartContainer.BarsWidth);
263 }
264
265 private decimal GetStartY(IndicatorCandle candle, int height)
266 {
267 var topHeight = ChartInfo.GetYByPrice(candle.High) - Offset - height;
268 var bottomHeight = ChartInfo.GetYByPrice(candle.Low) + Offset + ChartInfo.PriceChartContainer.PriceRowHeight;
269
270 return LabelLocation switch
271 {
272 LabelLocations.Top => topHeight,
273 LabelLocations.Bottom => bottomHeight,
274 LabelLocations.CandleDirection => candle.Open > candle.Close
275 ? bottomHeight
276 : topHeight,
277 _ => 0,
278 };
279 }
280
281 private Color GetColorTransparency(Color color, int tr = 5)
282 {
283 var colorA = Math.Max(color.A - (tr * 25), 0);
284
285 return Color.FromArgb((byte)colorA, color.R, color.G, color.B);
286 }
287
288 #endregion
289 }
modified 25-Nov-23 3:57am.
|
|
|
|
|
What is the exact error message?
|
|
|
|
|
cs1001 identifier expected its in line 201
|
|
|
|
|
I cannot see anything obvious in lines 200/201 or 280/281 that would cause this. Are you sure there are no other messages?
|
|
|
|
|
var prevCandle = GetCandle(bar-1);
var l20d = (candle.Low) < prevCandle.(_lowestX.Calculate(20, candle.Low));
this is giving me cs1001: identifier expected. im not getting where to correct that @ start of parenthisis of prevCandle.(
|
|
|
|
|
On line 201 you have the following:
var l20d = (candle.Low) < prevCandle.(_lowestX.Calculate(20, candle.Low));
^
but the period character after prevCandle implies a reference to a Property or Method. But the following expression in parentheses is neither.
|
|
|
|
|
im a beginner, im trying edit it according to my condition,, can there be any solution
//@version=5
indicator("VK", "Stop vol", overlay=true, max_bars_back = 500, max_boxes_count = 1000, max_lines_count = 250, max_labels_count = 500)
X = input(10)
av = (ta.sma(volume, X))
uhv = (volume > (2 * av))
r = high -low
ar = ta.sma(r,X)
uwrb = (r>(2*ar))
wrb = (r>(1.33*ar)) and (r<(2*ar))
u3 = close > (high-(r/3))
m3 = (close < (high - (r/3))) and (close > (low + (r/3)))
l20d = low < ta.lowest(low,20)[1]
sos = (close < close[1]) and ((volume > ta.highest(volume,3)[1] and l20d) or uhv) and (uwrb or wrb) and (m3 or u3)
plotshape(sos, style=shape.xcross, location = location.belowbar ,color= #2ebd85 ,text= 'sv' ,textcolor= #2ebd85 , size = size.auto)
this is compelte Tradingv iew code, im trying get l20d line
|
|
|
|
|
Sorry I have no idea what that code is supposed to represent.
|
|
|
|
|
l20d = low < ta.lowest(low,20)[1]
how to get this is c# that would be sufficient
|
|
|
|
|
That is a valid expression in C#. But that does not mean it will work. You need to understand what each variable represents and what the resulting values are expected to be.
|
|
|
|
|