回答編集履歴

2

見直しキャンペーン中

2023/08/10 10:49

投稿

TN8001
TN8001

スコア9862

test CHANGED
@@ -239,4 +239,26 @@
239
239
  </Grid>
240
240
  </Window>
241
241
  ```
242
+ ```cs
243
+ using System;
244
+ using System.Globalization;
245
+ using System.Windows;
246
+ using System.Windows.Data;
247
+
248
+ namespace Questions250393
249
+ {
250
+ public class PointConverter : IMultiValueConverter
251
+ {
252
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
253
+ => new Point((double)values[0], (double)values[1]);
254
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
255
+ => throw new NotImplementedException();
256
+ }
257
+ public partial class MainWindow : Window
258
+ {
259
+ public MainWindow() => InitializeComponent();
260
+ }
261
+ }
262
+ ```
263
+
242
264
  ![アプリ画像](1aa2ad9b45d91151d5ddf372284287e6.png)

1

見直しキャンペーン中

2023/07/21 09:21

投稿

TN8001
TN8001

スコア9862

test CHANGED
@@ -1,487 +1,242 @@
1
1
  ### グラデーション
2
-
3
2
  > 実際は必ずY方向に対してかかるみたいです。
4
3
 
5
-
6
-
7
4
  デフォルトだと右下方向ではありませんか?
8
5
 
9
-
10
-
11
- `StartPoint` `EndPoint`でどの方向にも向きますが、線だと扱いづらいですね。
6
+ `StartPoint``EndPoint`でどの方向にも向きますが、線だと扱いづらいですね。
12
-
13
7
  `MappingMode="Absolute"`にすればまだましそうです。
14
8
 
15
-
16
-
17
-
18
-
19
9
  ### エフェクト
20
-
21
- `OuterGlowBitmapEffect`等`BitmapEffect`はNET Framework 4で廃止になりました。
10
+ `OuterGlowBitmapEffect`等`BitmapEffect`は、.NET Framework 4で廃止になりました。
22
-
23
- 代替は`Effect`になります。
11
+
24
-
25
- 高速な上`ShaderEffect`を使えば何でもできそうですが、気の利いた面白いものを用意してくれていないです(`BlurEffect`と`DropShadowEffect`のみ)
12
+ 代替は`Effect`で高速な上`ShaderEffect`を使えば何でもできそうですが、気の利いた面白いものを用意してくれていないです(`BlurEffect`と`DropShadowEffect`のみ)
26
-
27
-
28
-
13
+
29
- 基本的には`DropShadowEffect`を使うしかなさそうです
14
+ 基本的には`DropShadowEffect`を使うしかなさそうです(光って見えるかどうかはよくわからないです^^;
30
-
31
- 光って見えるかどうかはよくわからないです^^;
15
+
32
-
33
-
34
-
35
- ```xaml
16
+ ```xml
36
-
37
17
  <Window
38
-
39
18
  x:Class="Questions250393.MainWindow"
40
-
41
19
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
42
-
43
20
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
-
45
21
  xmlns:local="clr-namespace:Questions250393"
46
-
47
22
  Width="800"
48
-
49
23
  Height="450">
50
-
51
24
  <Window.Resources>
52
-
53
25
  <!-- double2つをPointにして返すIMultiValueConverter -->
54
-
55
26
  <local:PointConverter x:Key="PointConverter" />
56
-
57
27
  </Window.Resources>
58
-
59
28
  <Grid>
60
-
61
29
  <Grid.ColumnDefinitions>
62
-
63
30
  <ColumnDefinition />
64
-
65
31
  <ColumnDefinition />
66
-
67
32
  </Grid.ColumnDefinitions>
68
-
69
33
 
70
-
71
34
  <GroupBox Header="グラデーション">
72
-
73
35
  <Canvas>
74
-
75
36
  <!-- デフォルト斜め -->
76
-
77
37
  <Rectangle Width="50" Height="50">
78
-
79
38
  <Rectangle.Fill>
80
-
81
39
  <LinearGradientBrush>
82
-
83
- <GradientStop Offset="0" Color="Red" />
40
+ <GradientStop Offset="0" Color="Red" />
84
-
85
- <GradientStop Offset="1" Color="Blue" />
41
+ <GradientStop Offset="1" Color="Blue" />
86
-
87
- </LinearGradientBrush>
42
+ </LinearGradientBrush>
88
-
89
43
  </Rectangle.Fill>
90
-
91
44
  </Rectangle>
92
-
93
45
  <!-- 縦 -->
94
-
95
46
  <Rectangle
96
-
97
47
  Canvas.Top="60"
98
-
99
48
  Width="50"
100
-
101
49
  Height="50">
102
-
103
50
  <Rectangle.Fill>
104
-
105
51
  <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
106
-
107
- <GradientStop Offset="0" Color="Red" />
52
+ <GradientStop Offset="0" Color="Red" />
108
-
109
- <GradientStop Offset="1" Color="Blue" />
53
+ <GradientStop Offset="1" Color="Blue" />
110
-
111
- </LinearGradientBrush>
54
+ </LinearGradientBrush>
112
-
113
55
  </Rectangle.Fill>
114
-
115
56
  </Rectangle>
116
-
117
57
  <!-- 横 -->
118
-
119
58
  <Rectangle
120
-
121
59
  Canvas.Top="120"
122
-
123
60
  Width="50"
124
-
125
61
  Height="50">
126
-
127
62
  <Rectangle.Fill>
128
-
129
63
  <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
130
-
131
- <GradientStop Offset="0" Color="Red" />
64
+ <GradientStop Offset="0" Color="Red" />
132
-
133
- <GradientStop Offset="1" Color="Blue" />
65
+ <GradientStop Offset="1" Color="Blue" />
134
-
135
- </LinearGradientBrush>
66
+ </LinearGradientBrush>
136
-
137
67
  </Rectangle.Fill>
138
-
139
68
  </Rectangle>
140
69
 
141
-
142
-
143
70
  <!-- X1,Y1が0で右か下方向ならStartPoint="0,0" EndPoint="1,1"で行ける -->
144
-
145
- <Line
71
+ <Line
146
-
147
- Canvas.Left="200"
72
+ Canvas.Left="200"
148
-
149
- Canvas.Top="100"
73
+ Canvas.Top="100"
150
-
151
- StrokeThickness="10"
74
+ StrokeThickness="10"
152
-
153
- X1="0"
75
+ X1="0"
154
-
155
- X2="100"
76
+ X2="100"
156
-
157
- Y1="0"
77
+ Y1="0"
158
-
159
78
  Y2="0">
160
-
161
- <Line.Stroke>
79
+ <Line.Stroke>
162
-
163
80
  <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
164
-
165
- <GradientStop Offset="0" Color="Red" />
81
+ <GradientStop Offset="0" Color="Red" />
166
-
167
- <GradientStop Offset="1" Color="Blue" />
82
+ <GradientStop Offset="1" Color="Blue" />
168
-
169
- </LinearGradientBrush>
83
+ </LinearGradientBrush>
170
-
171
- </Line.Stroke>
84
+ </Line.Stroke>
172
-
173
- </Line>
85
+ </Line>
174
-
175
- <Line
86
+ <Line
176
-
177
- Canvas.Left="200"
87
+ Canvas.Left="200"
178
-
179
- Canvas.Top="100"
88
+ Canvas.Top="100"
180
-
181
- StrokeThickness="10"
89
+ StrokeThickness="10"
182
-
183
- X1="0"
90
+ X1="0"
184
-
185
- X2="100"
91
+ X2="100"
186
-
187
- Y1="0"
92
+ Y1="0"
188
-
189
- Y2="100">
93
+ Y2="100">
190
-
191
- <Line.Stroke>
94
+ <Line.Stroke>
192
-
193
95
  <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
194
-
195
- <GradientStop Offset="0" Color="Red" />
96
+ <GradientStop Offset="0" Color="Red" />
196
-
197
- <GradientStop Offset="1" Color="Blue" />
97
+ <GradientStop Offset="1" Color="Blue" />
198
-
199
- </LinearGradientBrush>
98
+ </LinearGradientBrush>
200
-
201
- </Line.Stroke>
99
+ </Line.Stroke>
202
-
203
- </Line>
100
+ </Line>
204
-
205
- <Line
101
+ <Line
206
-
207
- Canvas.Left="200"
102
+ Canvas.Left="200"
208
-
209
- Canvas.Top="100"
103
+ Canvas.Top="100"
210
-
211
- StrokeThickness="10"
104
+ StrokeThickness="10"
212
-
213
- X1="0"
105
+ X1="0"
214
-
215
106
  X2="0"
216
-
217
- Y1="0"
107
+ Y1="0"
218
-
219
- Y2="100">
108
+ Y2="100">
220
-
221
- <Line.Stroke>
109
+ <Line.Stroke>
222
-
223
110
  <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
224
-
225
- <GradientStop Offset="0" Color="Red" />
111
+ <GradientStop Offset="0" Color="Red" />
226
-
227
- <GradientStop Offset="1" Color="Blue" />
112
+ <GradientStop Offset="1" Color="Blue" />
228
-
229
- </LinearGradientBrush>
113
+ </LinearGradientBrush>
230
-
231
- </Line.Stroke>
114
+ </Line.Stroke>
232
-
233
- </Line>
115
+ </Line>
234
-
235
-
236
116
 
237
117
  <!-- X2,Y2がマイナスになる場合MappingMode="Absolute" EndPointにマイナスで行けた -->
238
-
239
- <Line
118
+ <Line
240
-
241
- Canvas.Left="200"
119
+ Canvas.Left="200"
242
-
243
- Canvas.Top="100"
120
+ Canvas.Top="100"
244
-
245
- StrokeThickness="10"
121
+ StrokeThickness="10"
246
-
247
- X1="0"
122
+ X1="0"
248
-
249
123
  X2="-100"
250
-
251
- Y1="0"
124
+ Y1="0"
252
-
253
- Y2="100">
125
+ Y2="100">
254
-
255
- <Line.Stroke>
126
+ <Line.Stroke>
256
-
257
127
  <LinearGradientBrush MappingMode="Absolute" StartPoint="0,0" EndPoint="-100,100">
258
-
259
- <GradientStop Offset="0" Color="Red" />
128
+ <GradientStop Offset="0" Color="Red" />
260
-
261
- <GradientStop Offset="1" Color="Blue" />
129
+ <GradientStop Offset="1" Color="Blue" />
262
-
263
- </LinearGradientBrush>
130
+ </LinearGradientBrush>
264
-
265
- </Line.Stroke>
131
+ </Line.Stroke>
266
-
267
- </Line>
132
+ </Line>
268
-
269
133
  <!-- べた置きでも同様 -->
270
-
271
- <Line
134
+ <Line
272
-
273
- StrokeThickness="10"
135
+ StrokeThickness="10"
274
-
275
136
  X1="200"
276
-
277
- X2="100"
137
+ X2="100"
278
-
279
138
  Y1="100"
280
-
281
- Y2="100">
139
+ Y2="100">
282
-
283
- <Line.Stroke>
140
+ <Line.Stroke>
284
-
285
141
  <LinearGradientBrush MappingMode="Absolute" StartPoint="200,100" EndPoint="100,100">
286
-
287
- <GradientStop Offset="0" Color="Red" />
142
+ <GradientStop Offset="0" Color="Red" />
288
-
289
- <GradientStop Offset="1" Color="Blue" />
143
+ <GradientStop Offset="1" Color="Blue" />
290
-
291
- </LinearGradientBrush>
144
+ </LinearGradientBrush>
292
-
293
- </Line.Stroke>
145
+ </Line.Stroke>
294
-
295
- </Line>
146
+ </Line>
296
-
297
147
  <!-- バインドできなくはないがどうなのか。。。 -->
298
-
299
- <Line
148
+ <Line
300
-
301
- StrokeThickness="10"
149
+ StrokeThickness="10"
302
-
303
150
  X1="200"
304
-
305
- X2="100"
151
+ X2="100"
306
-
307
152
  Y1="100"
308
-
309
153
  Y2="0">
310
-
311
- <Line.Stroke>
154
+ <Line.Stroke>
312
-
313
155
  <LinearGradientBrush MappingMode="Absolute">
314
-
315
156
  <LinearGradientBrush.StartPoint>
316
-
317
157
  <MultiBinding Converter="{StaticResource PointConverter}">
318
-
319
158
  <Binding Path="X1" RelativeSource="{RelativeSource FindAncestor, AncestorType=Line}" />
320
-
321
159
  <Binding Path="Y1" RelativeSource="{RelativeSource FindAncestor, AncestorType=Line}" />
322
-
323
160
  </MultiBinding>
324
-
325
161
  </LinearGradientBrush.StartPoint>
326
-
327
162
  <LinearGradientBrush.EndPoint>
328
-
329
163
  <MultiBinding Converter="{StaticResource PointConverter}">
330
-
331
164
  <Binding Path="X2" RelativeSource="{RelativeSource FindAncestor, AncestorType=Line}" />
332
-
333
165
  <Binding Path="Y2" RelativeSource="{RelativeSource FindAncestor, AncestorType=Line}" />
334
-
335
166
  </MultiBinding>
336
-
337
167
  </LinearGradientBrush.EndPoint>
338
-
339
- <GradientStop Offset="0" Color="Red" />
168
+ <GradientStop Offset="0" Color="Red" />
340
-
341
- <GradientStop Offset="1" Color="Blue" />
169
+ <GradientStop Offset="1" Color="Blue" />
342
-
343
- </LinearGradientBrush>
170
+ </LinearGradientBrush>
344
-
345
- </Line.Stroke>
171
+ </Line.Stroke>
346
-
347
- </Line>
172
+ </Line>
348
-
349
173
  </Canvas>
350
-
351
174
  </GroupBox>
352
175
 
353
-
354
-
355
176
  <GroupBox Grid.Column="1" Header="エフェクト">
356
-
357
177
  <Canvas>
358
-
359
178
  <!-- ブラー -->
360
-
361
- <Line
179
+ <Line
362
-
363
180
  Canvas.Left="50"
364
-
365
181
  Canvas.Top="50"
366
-
367
182
  Stroke="Green"
368
-
369
- StrokeThickness="2"
183
+ StrokeThickness="2"
370
-
371
184
  X2="100" />
372
-
373
- <Line
185
+ <Line
374
-
375
- Canvas.Left="200"
186
+ Canvas.Left="200"
376
-
377
187
  Canvas.Top="50"
378
-
379
188
  Stroke="Green"
380
-
381
- StrokeThickness="2"
189
+ StrokeThickness="2"
382
-
383
190
  X2="100">
384
-
385
191
  <Line.Effect>
386
-
387
192
  <BlurEffect Radius="5" />
388
-
389
193
  </Line.Effect>
390
-
391
- </Line>
194
+ </Line>
392
-
393
-
394
195
 
395
196
  <!-- ドロップシャドウ -->
396
-
397
- <Line
197
+ <Line
398
-
399
198
  Canvas.Left="50"
400
-
401
- Canvas.Top="100"
199
+ Canvas.Top="100"
402
-
403
200
  Stroke="Blue"
404
-
405
- StrokeThickness="2"
201
+ StrokeThickness="2"
406
-
407
202
  X2="100" />
408
-
409
- <Line
203
+ <Line
410
-
411
- Canvas.Left="200"
204
+ Canvas.Left="200"
412
-
413
- Canvas.Top="100"
205
+ Canvas.Top="100"
414
-
415
206
  Stroke="Blue"
416
-
417
- StrokeThickness="2"
207
+ StrokeThickness="2"
418
-
419
208
  X2="100">
420
-
421
209
  <Line.Effect>
422
-
423
210
  <DropShadowEffect
424
-
425
211
  BlurRadius="8"
426
-
427
212
  ShadowDepth="0"
428
-
429
213
  Color="Blue" />
430
-
431
214
  </Line.Effect>
432
-
433
- </Line>
215
+ </Line>
434
-
435
-
436
216
 
437
217
  <!-- 色を変えたほうが見栄えがいい? どう変えるんだという話だが -->
438
-
439
- <Line
218
+ <Line
440
-
441
219
  Canvas.Left="50"
442
-
443
220
  Canvas.Top="150"
444
-
445
221
  Stroke="Red"
446
-
447
- StrokeThickness="2"
222
+ StrokeThickness="2"
448
-
449
223
  X2="100" />
450
-
451
- <Line
224
+ <Line
452
-
453
- Canvas.Left="200"
225
+ Canvas.Left="200"
454
-
455
226
  Canvas.Top="150"
456
-
457
227
  Stroke="Red"
458
-
459
- StrokeThickness="2"
228
+ StrokeThickness="2"
460
-
461
229
  X2="100">
462
-
463
230
  <Line.Effect>
464
-
465
231
  <DropShadowEffect
466
-
467
232
  BlurRadius="8"
468
-
469
233
  ShadowDepth="0"
470
-
471
234
  Color="DeepPink" />
472
-
473
235
  </Line.Effect>
474
-
475
- </Line>
236
+ </Line>
476
-
477
237
  </Canvas>
478
-
479
238
  </GroupBox>
480
-
481
239
  </Grid>
482
-
483
240
  </Window>
484
-
485
241
  ```
486
-
487
242
  ![アプリ画像](1aa2ad9b45d91151d5ddf372284287e6.png)