/
Popup.cs
executable file
·835 lines (769 loc) · 28.9 KB
/
Popup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
/*
* Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* 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.
*
*/
using System;
using System.Collections.Generic;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
using System.ComponentModel;
namespace Tizen.NUI.Components
{
/// <summary>
/// Popup is one kind of common component, it can be used as popup window.
/// User can handle Popup button count, head title and content area.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public class Popup : Control
{
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonHeightProperty = BindableProperty.Create(nameof(ButtonHeight), typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null && instance?.Style?.Buttons?.Size != null )
{
instance.Style.Buttons.Size.Height = (int)newValue;
instance.btGroup.Itemheight = (int)newValue;
instance.UpdateView();
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return (int)(instance.Style?.Buttons?.Size?.Height ?? 0);
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonTextPointSizeProperty = BindableProperty.Create(nameof(ButtonTextPointSize), typeof(float), typeof(Popup), default(float), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null)
{
if (instance.Style?.Buttons?.Text != null)
{
instance.Style.Buttons.Text.PointSize = (float)newValue;
}
instance.btGroup.ItemPointSize = (float)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.Text?.PointSize?.All ?? 0;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonFontFamilyProperty = BindableProperty.Create(nameof(ButtonFontFamily), typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null)
{
instance.Style.Buttons.Text.FontFamily = (string)newValue;
instance.btGroup.ItemFontFamily = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.Text?.FontFamily.All;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonTextColorProperty = BindableProperty.Create(nameof(ButtonTextColor), typeof(Color), typeof(Popup), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null)
{
if (instance.Style?.Buttons?.Text != null)
{
instance.Style.Buttons.Text.TextColor = (Color)newValue;
}
instance.btGroup.ItemTextColor = (Color)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.Text?.TextColor?.All;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonOverLayBackgroundColorSelectorProperty = BindableProperty.Create(nameof(ButtonOverLayBackgroundColorSelector), typeof(Selector<Color>), typeof(Popup), new Selector<Color>(), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null)
{
instance.Style.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
instance.btGroup.OverLayBackgroundColorSelector = (Selector<Color>)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.Overlay?.BackgroundColor;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonTextAlignmentProperty = BindableProperty.Create(nameof(ButtonTextAlignment), typeof(HorizontalAlignment), typeof(Popup), new HorizontalAlignment(), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null)
{
instance.Style.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
instance.btGroup.ItemTextAlignment = (HorizontalAlignment)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonBackgroundProperty = BindableProperty.Create(nameof(ButtonBackground), typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null)
{
if (instance.Style.Buttons.BackgroundImage == null)
{
instance.Style.Buttons.BackgroundImage = new Selector<string>();
}
instance.btGroup.ItemBackgroundImageUrl = (string)newValue;
instance.Style.Buttons.BackgroundImage = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.BackgroundImage?.All;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonBackgroundBorderProperty = BindableProperty.Create(nameof(ButtonBackgroundBorder), typeof(Rectangle), typeof(Popup), new Rectangle(0, 0, 0, 0), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
if (newValue != null)
{
if (instance.Style.Buttons.BackgroundImageBorder == null)
{
instance.Style.Buttons.BackgroundImageBorder = new Selector<Rectangle>();
}
instance.Style.Buttons.BackgroundImageBorder = (Rectangle)newValue;
instance.btGroup.ItemBackgroundBorder = (Rectangle)newValue;
}
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.BackgroundImageBorder?.All;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonImageShadowProperty = BindableProperty.Create(nameof(ButtonImageShadow), typeof(ImageShadow), typeof(Popup), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
ImageShadow shadow = (ImageShadow)newValue;
instance.btGroup.ItemImageShadow = (ImageShadow)ImageShadow.Clone(shadow);
instance.Style.Buttons.ImageShadow = (ImageShadow)ImageShadow.Clone(shadow);
},
defaultValueCreator: (bindable) =>
{
var instance = (Popup)bindable;
return instance.Style?.Buttons?.ImageShadow?.All;
});
private TextLabel titleText;
private ButtonGroup btGroup = null;
private Window window = null;
private Layer container = new Layer();
static Popup() { }
/// <summary>
/// Creates a new instance of a Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public Popup() : base()
{
Initialize();
}
/// <summary>
/// Creates a new instance of a Popup with style.
/// </summary>
/// <param name="style">Create Popup by special style defined in UX.</param>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Popup(string style) : base(style)
{
Initialize();
}
/// <summary>
/// Creates a new instance of a Popup with attributes.
/// </summary>
/// <param name="attributes">Create Popup by attributes customized by user.</param>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Popup(PopupStyle attributes) : base(attributes)
{
Initialize();
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void Post(Window targetWindow)
{
if (targetWindow == null)
{
return;
}
window = targetWindow;
window.AddLayer(container);
container.RaiseToTop();
}
/// <summary>
/// Dismiss the dialog
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void Dismiss()
{
if (window == null)
{
return;
}
window.RemoveLayer(container);
window = null;
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddButton(string buttonText)
{
if (Style.Buttons != null)
{
Button btn = new Button(Style.Buttons);
btn.Style.Text.Text = buttonText;
btn.ClickEvent += ButtonClickEvent;
btGroup.AddItem(btn);
UpdateView();
}
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddButton(string buttonText, string style)
{
AddButton(buttonText);
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddButton(string buttonText, ButtonStyle style)
{
if (Style.Buttons != null && style != null)
{
Style.Buttons.CopyFrom(style);
AddButton(buttonText);
}
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Button GetButton(int index)
{
return btGroup.GetItem(index);
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void RemoveButton(int index)
{
btGroup.RemoveItem(index);
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddContentText(View childView)
{
if (null != ContentView)
{
ContentView.Add(childView);
}
UpdateView();
}
/// <summary>
/// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
/// </summary>
/// <since_tizen> 6 </since_tizen>
public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public new PopupStyle Style => ViewStyle as PopupStyle;
/// <summary>
/// Title text string in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public string TitleText
{
get
{
return Style?.Title?.Text?.All;
}
set
{
if (value != null)
{
if (Style?.Title != null)
{
Style.Title.Text = value;
}
}
}
}
/// <summary>
/// Title text point size in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public float TitlePointSize
{
get
{
return Style?.Title?.PointSize?.All ?? 0;
}
set
{
if (Style?.Title != null)
{
Style.Title.PointSize = value;
}
}
}
/// <summary>
/// Title text color in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public Color TitleTextColor
{
get
{
return Style?.Title?.TextColor?.All;
}
set
{
if (Style?.Title != null)
{
Style.Title.TextColor = value;
}
}
}
/// <summary>
/// Title text horizontal alignment in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public HorizontalAlignment TitleTextHorizontalAlignment
{
get
{
return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
}
set
{
Style.Title.HorizontalAlignment = value;
}
}
/// <summary>
/// Title text's position in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public Position TitleTextPosition
{
get
{
return Style?.Title?.Position ?? new Position(0, 0, 0);
}
set
{
Style.Title.Position = value;
}
}
/// <summary>
/// Title text's height in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public int TitleHeight
{
get
{
return (int)(Style?.Title?.Size?.Height ?? 0);
}
set
{
if (Style?.Title?.Size != null)
{
Style.Title.Size.Height = value;
}
}
}
/// <summary>
/// Content view in Popup, only can be gotten.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public View ContentView
{
get;
private set;
}
/// <summary>
/// Button count in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public int ButtonCount
{
get;
set;
}
/// <summary>
/// Button height in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public int ButtonHeight
{
get
{
return (int)GetValue(ButtonHeightProperty);
}
set
{
SetValue(ButtonHeightProperty, value);
}
}
/// <summary>
/// Button text point size in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public float ButtonTextPointSize
{
get
{
return (float)GetValue(ButtonTextPointSizeProperty);
}
set
{
SetValue(ButtonTextPointSizeProperty, value);
}
}
/// <summary>
/// Button text font family in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public string ButtonFontFamily
{
get
{
return (string)GetValue(ButtonFontFamilyProperty);
}
set
{
SetValue(ButtonFontFamilyProperty, value);
}
}
/// <summary>
/// Button text color in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public Color ButtonTextColor
{
get
{
return (Color)GetValue(ButtonTextColorProperty);
}
set
{
SetValue(ButtonTextColorProperty, value);
}
}
/// <summary>
/// Button overlay background color selector in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Selector<Color> ButtonOverLayBackgroundColorSelector
{
get
{
return (Selector<Color>)GetValue(ButtonOverLayBackgroundColorSelectorProperty);
}
set
{
SetValue(ButtonOverLayBackgroundColorSelectorProperty, value);
}
}
/// <summary>
/// Button text horizontal alignment in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public HorizontalAlignment ButtonTextAlignment
{
get
{
return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
}
set
{
SetValue(ButtonTextAlignmentProperty, value);
}
}
/// <summary>
/// Button background image's resource url in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public string ButtonBackground
{
get
{
return (string)GetValue(ButtonBackgroundProperty);
}
set
{
SetValue(ButtonBackgroundProperty, value);
}
}
/// <summary>
/// Button background image's border in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Rectangle ButtonBackgroundBorder
{
get
{
return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
}
set
{
SetValue(ButtonBackgroundBorderProperty, value);
}
}
/// <summary>
/// Button's image shadow in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public ImageShadow ButtonImageShadow
{
get => (ImageShadow)GetValue(ButtonImageShadowProperty);
set => SetValue(ButtonImageShadowProperty, value);
}
/// <summary>
/// Set button text by index.
/// </summary>
/// <param name="index">Button index.</param>
/// <param name="text">Button text string.</param>
/// <since_tizen> 6 </since_tizen>
public void SetButtonText(int index, string text)
{
AddButton(text);
}
/// <summary>
/// Dispose Popup and all children on it.
/// </summary>
/// <param name="type">Dispose type.</param>
/// <since_tizen> 6 </since_tizen>
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
if (type == DisposeTypes.Explicit)
{
if (titleText != null)
{
Remove(titleText);
titleText.Dispose();
titleText = null;
}
if (ContentView != null)
{
Remove(ContentView);
ContentView.Dispose();
ContentView = null;
}
if (btGroup != null)
{
btGroup.Dispose();
btGroup = null;
}
}
base.Dispose(type);
}
/// <summary>
/// Focus gained callback.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public override void OnFocusGained()
{
base.OnFocusGained();
}
/// <summary>
/// Focus lost callback.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public override void OnFocusLost()
{
base.OnFocusLost();
}
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public override void ApplyStyle(ViewStyle viewStyle)
{
base.ApplyStyle(viewStyle);
PopupStyle ppStyle = viewStyle as PopupStyle;
if (null != ppStyle)
{
if (null == titleText)
{
titleText = new TextLabel();
Add(titleText);
}
titleText.RaiseToTop();
titleText.ApplyStyle(ppStyle.Title);
}
}
/// <summary>
/// Get Popup attribues.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override ViewStyle GetViewStyle()
{
return new PopupStyle();
}
/// <summary>
/// Theme change callback when theme is changed, this callback will be trigger.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
{
PopupStyle tempAttributes = StyleManager.Instance.GetViewStyle(style) as PopupStyle;
if (tempAttributes != null)
{
string strSaveTitleText = TitleText;
Style.CopyFrom(tempAttributes);
Style.Title.Text = strSaveTitleText;
UpdateView();
}
}
private void Initialize()
{
container.Add(this);
LeaveRequired = true;
PropertyChanged += PopupAttributesPropertyChanged;
// ContentView
ContentView = new View()
{
ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
PositionUsesPivotPoint = true
};
Add(ContentView);
ContentView.RaiseToTop();
// Title
if (null == titleText)
{
titleText = new TextLabel();
titleText.RaiseToTop();
Add(titleText);
}
// Button
btGroup = new ButtonGroup(this);
}
private void UpdateView()
{
btGroup.UpdateButton(Style.Buttons);
UpdateContentView();
UpdateTitle();
}
private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
{
if (PopupButtonClickEvent != null && btGroup.Count > 0)
{
Button button = sender as Button;
for (int i = 0; i < btGroup.Count; i++)
{
if (button == GetButton(i))
{
ButtonClickEventArgs args = new ButtonClickEventArgs();
args.ButtonIndex = i;
PopupButtonClickEvent(this, args);
}
}
}
}
private void PopupAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName.Equals("LayoutDirection"))
{
btGroup.UpdateButton(Style.Buttons);
}
}
private void UpdateContentView()
{
int titleX = 0;
int titleY = 0;
int titleH = 0;
int buttonH = 0;
string strText = Style.Title.Text.All;
if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
{
titleH = (int)titleText.Size.Height;
}
if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
{
titleX = (int)Style.Title.Position.X;
titleY = (int)Style.Title.Position.Y;
}
if (btGroup.Count != 0 && Style?.Buttons?.Size != null )
{
buttonH = (int)Style.Buttons.Size.Height;
}
ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
ContentView.Position = new Position(titleX, titleY + titleH);
ContentView.RaiseToTop();
}
private void UpdateTitle()
{
if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
{
titleText.RaiseToTop();
}
}
/// <summary>
/// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public class ButtonClickEventArgs : EventArgs
{
/// <summary> Button index which is clicked in Popup </summary>
/// <since_tizen> 6 </since_tizen>
public int ButtonIndex;
}
}
}