프로젝트

일반

사용자정보

개정판 3074202c

ID3074202ce927936206da0ae8bcf0c1e9dcf889c1
상위 96c13fad
하위 48f69651

송근호이(가) 5년 이상 전에 추가함

issue #1127 : TextControl, ArrowTextContol 각각 컨트롤에 Customizing Cursor를 적용
기존 Caret에 대한 처리는 Color를 Transparent 를 주어, 투명화 만들었다.
Database에서 불러온 각각 컨트롤에 대해 생성자에서 ApplyTemplate을 적용해줘야, TextBox안의 지정된 된 인덱스에 있는 문자의 선행 모서리에 대한 사각형 Caret의 위치를 알아 낼 수 있다.

Change-Id: I38c55393118686179fc8f762f82cc54c09cf87bb

차이점 보기:

MarkupToPDF/Controls/Text/ArrowTextControl.cs
23 23
        //private const string PART_TextBlock = "PART_ArrowTextBlock";
24 24
        private const string PART_ArrowSubPath = "PART_ArrowSubPath";
25 25
        private const string PART_Border = "PART_Border";
26
        
26
        private const string PART_BaseTextbox_Caret = "Caret";
27

  
27 28
        public Path Base_ArrowPath = null;
28 29
        public Path Base_ArrowSubPath = null;
29 30
        public TextBox Base_TextBox = null;
30 31
        public TextBlock Base_TextBlock = null;
32
        public Border BaseTextbox_Caret = null;
31 33

  
32 34
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
33 35

  
......
61 63
            Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path;
62 64
            Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path;
63 65
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
66
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
67

  
68
           
69
            this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
70
            this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
71
            this.Base_TextBox.ApplyTemplate();
72
            MoveCustomCaret();
64 73

  
65 74
            Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
66 75
            Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
67 76
            Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
77
            Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
68 78

  
69 79
            SetArrowTextPath();
70 80
            Base_TextBox.IsTabStop = true;
71 81
        }
72 82

  
83
        /// <summary>
84
        /// Moves the custom caret on the canvas.
85
        /// </summary>
86
        public void MoveCustomCaret()
87
        {
88

  
89
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
90

  
91
            if (!double.IsInfinity(caretLocation.X))
92
            {
93
                
94
                Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X);
95
            }
96

  
97
            if (!double.IsInfinity(caretLocation.Y))
98
            {
99
                Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y + caretLocation.Y);
100
            }
101
        }
102

  
103

  
73 104
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
74 105
        {
106
            
75 107
            this.ArrowText = Base_TextBox.Text;
108
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
76 109
            this.IsEditingMode = false;
77 110
            ApplyOverViewData();
78 111
        }
79 112

  
80 113
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
81 114
        {
82
          
115
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
83 116
            this.IsEditingMode = true;
84 117
        }
85 118

  
......
1191 1224
                CenterX = this.EndPoint.X,
1192 1225
                CenterY = this.EndPoint.Y,
1193 1226
            };
1227
            MoveCustomCaret();
1194 1228
        }
1195 1229

  
1196 1230
        private void DrawingCloud()
MarkupToPDF/Controls/Text/TextControl.cs
30 30
        private const string PART_TextPath = "PART_TextPath";
31 31
        private const string PART_TextBlock = "PART_TextBlock";
32 32
        private const string PART_Canvas = "PART_TextControlCanvas";
33
        private const string PART_BaseTextbox_Caret = "Caret";
34
        
33 35
        //private const string PART_TextPrefix = "PART_TextPrefix";
34

  
36
      
35 37
        public Path Base_TextPath = null;
36 38
        public Grid Base_Grid = null;
37 39
        public Border Base_Border = null;
......
39 41
        //public TextBlock Base_TextPrefixBlock = null;
40 42
        public TextBlock Base_TextBlock = null;
41 43
        public TextBox Base_TextBox = null;
44
        public Border BaseTextbox_Caret = null;
42 45

  
43 46
        public RotateTransform _rotation = null;
44 47
        public TranslateTransform _translation = null;
......
86 89
            Base_Grid = GetTemplateChild(PART_Grid) as Grid;
87 90
            Base_Border = GetTemplateChild(PART_Border) as Border;
88 91
            Base_Canvas = GetTemplateChild(PART_Canvas) as Canvas;
89
           
92
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
93
            this.Base_TextBox.Text = this.Text;
94
            this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
95
            this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
96
            this.Base_TextBox.ApplyTemplate();
97
            MoveCustomCaret();
98

  
90 99
            this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
91 100
            this.Base_TextBlock.SizeChanged += new SizeChangedEventHandler(Base_TextBlock_SizeChanged);
92 101
            this.Base_TextBox.GotFocus += new RoutedEventHandler(TextControl_GotFocus);
93 102
            this.Base_TextBox.LostFocus += new RoutedEventHandler(TextControl_LostFocus);
94
            Base_TextBox.Text = this.Text;
95
            this.Base_TextBox.TextChanged += Base_TextBox_TextChanged;
103
            this.Base_TextBox.TextChanged += new TextChangedEventHandler(Base_TextBox_TextChanged);
104
            this.Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
96 105
            
97 106
            DrawingCloud();
98 107
            SetText();
108

  
109
            
110
            
111

  
112
        }
113
        /// <summary>
114
        /// Moves the custom caret on the canvas.
115
        /// </summary>
116
        public void MoveCustomCaret()
117
        {
118

  
119
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
120

  
121
            if (!double.IsInfinity(caretLocation.X)) {
122
                Canvas.SetLeft(this.BaseTextbox_Caret, caretLocation.X);
123
            }
124

  
125
            if (!double.IsInfinity(caretLocation.Y)) {
126
                Canvas.SetTop(this.BaseTextbox_Caret, caretLocation.Y);
127
            }
99 128
        }
100 129

  
101 130
        private void Base_TextBox_TextChanged(object sender, TextChangedEventArgs e)
......
106 135
           
107 136
            
108 137
            this.Text = Base_TextBox.Text;
138
           
109 139

  
110 140
            DrawingCloud();
111 141
        }
......
122 152
        {
123 153
            BoxWidth = e.NewSize.Width;
124 154
            BoxHeight = e.NewSize.Height;
155
           
125 156
            DrawingCloud();
126 157
        }
127 158

  
......
142 173
            if (EnableEditing)
143 174
            {
144 175
                EditingMode();
176
                
145 177
            }
146 178
            else
147 179
            {
180
                
148 181
                UnEditingMode();
149 182
            }
150 183
        }
......
188 221
        {
189 222
            //this.Base_TextBox.Focus();
190 223
            //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToLongTimeString());
224
            
225

  
191 226
            TextBoxVisibility = Visibility.Visible;
192 227
            //Base_TextBox.Visibility = System.Windows.Visibility.Visible;
193 228

  
194 229
            TextBlockVisibility = Visibility.Collapsed;
195 230
            //Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed;
196

  
197

  
231
            this.BaseTextbox_Caret.Visibility = Visibility.Visible; 
232
            
198 233
            //this.Base_TextBox.BorderThickness = new Thickness(1);
199 234

  
200 235
            if (UnderLine != null)
201 236
                Base_TextBlock.TextDecorations = UnderLine;
202 237

  
203
            if (this.Text != null)
204
                Base_TextBox.Text = this.Text;
205

  
238
            if (this.Text != null) {
239
                this.Base_TextBox.Text = this.Text;
240
                MoveCustomCaret();
241
                //this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
242
                //this.Base_TextBox.Select(Base_TextBox.Text.Length, 0);
243
            }
244
            
206 245
            //            Base_TextBox.Margin =
207 246
            //new Thickness(Base_TextBlock.Margin.Left + -2, Base_TextBlock.Margin.Top + 0,
208 247
            //Base_TextBlock.Margin.Right + 0, Base_TextBlock.Margin.Bottom + -2);
......
213 252
            if (EnableEditing)
214 253
                this.Text = Base_TextBox.Text;
215 254

  
255
            this.Base_TextBox.Select(Base_TextBox.Text.Length, 0);
256

  
216 257
            TextBoxVisibility = Visibility.Collapsed;
217 258
            //Base_TextBox.Visibility = System.Windows.Visibility.Collapsed;
218 259

  
219 260
            TextBlockVisibility = Visibility.Visible;
220 261
            //Base_TextBlock.Visibility = System.Windows.Visibility.Visible;
221 262

  
263
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
264

  
222 265
            if (UnderLine != null)
223 266
                Base_TextBlock.TextDecorations = UnderLine;
224 267

  
......
240 283
        public void SetText()
241 284
        {
242 285
            this.ApplyTemplate();
286

  
243 287
            if (IsHighLight)
244 288
            {
245 289
                this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6),
......
272 316
                new Point(0 + BoxWidth + 2, 0 + BoxHeight + 0),
273 317
                new Point(0 + BoxWidth + 2 ,0),
274 318
            };
275

  
319
            //this.Base_TextBox.Select(Base_TextBox.Text.Length, 0);
276 320
            if (Base_TextPath != null)
277 321
            {
278 322
                switch (ControlType_No)
MarkupToPDF/Themes/generic.xaml
343 343
                                </TextBlock>
344 344
                            </Border>
345 345

  
346

  
346 347
                            <TextBox x:Name="PART_TextBox" Text="{TemplateBinding Text}" Foreground="{TemplateBinding StrokeColor}"  IsTabStop="False" AcceptsTab="False"
347
                                     Visibility="{Binding TextBoxVisibility, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Padding="2"  
348
								      TextWrapping="Wrap"  Background="{TemplateBinding BackColor}" FontSize="{TemplateBinding TextSize}" AcceptsReturn="True" 
349
                                     FontFamily="{TemplateBinding TextFamily}" FontStyle="{TemplateBinding TextStyle}" FontWeight="{TemplateBinding TextWeight}"
350
                                     >
348
                                        Visibility="{Binding TextBoxVisibility, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Padding="2"  
349
								        TextWrapping="Wrap"  Background="{TemplateBinding BackColor}" FontSize="{TemplateBinding TextSize}" AcceptsReturn="True" 
350
                                        FontFamily="{TemplateBinding TextFamily}" FontStyle="{TemplateBinding TextStyle}" FontWeight="{TemplateBinding TextWeight}"
351
                                        >
351 352
                            </TextBox>
353

  
354

  
355
                            <Canvas>
356
                                <Border x:Name="Caret" 
357
                                        Visibility="Collapsed"
358
                                        Canvas.Left="0" 
359
                                        Canvas.Top="0" 
360
                                        Width="3" 
361
                                        Height="33" 
362
                                        Background="Red">
363
                                    <Border.Triggers>
364
                                        <EventTrigger RoutedEvent="Border.Loaded">
365
                                            <BeginStoryboard>
366
                                                <Storyboard  x:Name="CaretStoryBoard" 
367
                                                                 RepeatBehavior="Forever">
368
                                                    <ColorAnimationUsingKeyFrames 
369
                                                                Storyboard.TargetProperty="Background.Color"
370
                                                                Duration="0:0:0:1"
371
                                                                FillBehavior="HoldEnd">
372
                                                        <ColorAnimationUsingKeyFrames.KeyFrames >
373
                                                            <DiscreteColorKeyFrame KeyTime="0:0:0.750" Value="Transparent" />
374
                                                            <DiscreteColorKeyFrame KeyTime="0:0:0.000" Value="Black"/>
375
                                                        </ColorAnimationUsingKeyFrames.KeyFrames>
376
                                                    </ColorAnimationUsingKeyFrames>
377
                                                </Storyboard>
378
                                            </BeginStoryboard>
379
                                        </EventTrigger>
380
                                    </Border.Triggers>
381
                                </Border>
382
                            </Canvas>
352 383
                        </Grid>
353 384

  
354 385
                        <Path Stroke="Transparent" Data="{TemplateBinding PathDataInner}" RenderTransformOrigin="0,0" Canvas.ZIndex="0" IsHitTestVisible="False"  
......
508 539
                            </TextBlock.RenderTransform>
509 540
                        </TextBlock>-->
510 541

  
511
                        <TextBox x:Name="PART_ArrowTextBox"  
512
                                     Margin="0.5" Canvas.ZIndex="4"
513
                                     Background="{TemplateBinding TextBoxBackground}"
514
                                     BorderThickness="{TemplateBinding BorderSize}" 
515
                                     BorderBrush="{TemplateBinding StrokeColor}"
516
                                     FontSize="{TemplateBinding TextSize}" 
517
                                     FontFamily="{TemplateBinding TextFamily}"
518
                                     FontStyle="{TemplateBinding TextStyle}"
519
								     FontWeight="{TemplateBinding TextWeight}"
520
                                     TextDecorations="{TemplateBinding UnderLine}"
521
                                     AcceptsReturn="True" 
522
                                     Foreground="{TemplateBinding StrokeColor}" 
523
                                     HorizontalAlignment="Stretch"
524
                                     TextWrapping="Wrap" 
525
                                     Text="{TemplateBinding ArrowText}"
526
                                     RenderTransformOrigin="0.5,0.5">
527
                            <TextBox.RenderTransform>
528
                                <RotateTransform Angle="{Binding Angle, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
529
                                                    CenterX="{Binding CenterX, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
530
                                                    CenterY="{Binding CenterY, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
531
                                </RotateTransform>
532
                            </TextBox.RenderTransform>
533
                        </TextBox>
542

  
543
                            <TextBox x:Name="PART_ArrowTextBox"  
544
                                         Margin="0.5" Canvas.ZIndex="4"
545
                                         Background="{TemplateBinding TextBoxBackground}"
546
                                         BorderThickness="{TemplateBinding BorderSize}" 
547
                                         BorderBrush="{TemplateBinding StrokeColor}"
548
                                         FontSize="{TemplateBinding TextSize}" 
549
                                         FontFamily="{TemplateBinding TextFamily}"
550
                                         FontStyle="{TemplateBinding TextStyle}"
551
								         FontWeight="{TemplateBinding TextWeight}"
552
                                         TextDecorations="{TemplateBinding UnderLine}"
553
                                         AcceptsReturn="True" 
554
                                         Foreground="{TemplateBinding StrokeColor}" 
555
                                         HorizontalAlignment="Stretch"
556
                                         TextWrapping="Wrap" 
557
                                         Text="{TemplateBinding ArrowText}"
558
                                         RenderTransformOrigin="0.5,0.5">
559
                                <TextBox.RenderTransform>
560
                                    <RotateTransform Angle="{Binding Angle, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
561
                                                        CenterX="{Binding CenterX, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
562
                                                        CenterY="{Binding CenterY, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
563
                                    </RotateTransform>
564
                                </TextBox.RenderTransform>
565
                            </TextBox>
566

  
567
                        <Canvas Canvas.ZIndex="5">
568
                              
569
                            <Border x:Name="Caret" 
570
                                            Visibility="Collapsed"
571
                                            Canvas.Left="0" 
572
                                            Canvas.Top="0" 
573
                                            Width="3" 
574
                                            Height="33" 
575
                                            Background="Red"
576
                                           
577
                                            RenderTransformOrigin="0.5,0.5">
578
                                <Border.RenderTransform>
579
                                    <RotateTransform Angle="{Binding Angle, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
580
                                                                CenterX="{Binding CenterX, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
581
                                                                CenterY="{Binding CenterY, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
582
                                    </RotateTransform>
583
                                </Border.RenderTransform>
584
                                <Border.Triggers>
585
                                        <EventTrigger RoutedEvent="Border.Loaded">
586
                                            <BeginStoryboard>
587
                                                <Storyboard  x:Name="CaretStoryBoard" 
588
                                                                     RepeatBehavior="Forever">
589
                                                    <ColorAnimationUsingKeyFrames 
590
                                                                    Storyboard.TargetProperty="Background.Color"
591
                                                                    Duration="0:0:0:1"
592
                                                                    FillBehavior="HoldEnd">
593
                                                        <ColorAnimationUsingKeyFrames.KeyFrames >
594
                                                            <DiscreteColorKeyFrame KeyTime="0:0:0.750" Value="Transparent" />
595
                                                            <DiscreteColorKeyFrame KeyTime="0:0:0.000" Value="Black"/>
596
                                                        </ColorAnimationUsingKeyFrames.KeyFrames>
597
                                                    </ColorAnimationUsingKeyFrames>
598
                                                </Storyboard>
599
                                            </BeginStoryboard>
600
                                        </EventTrigger>
601
                                    </Border.Triggers>
602
                                </Border>
603
                            </Canvas>
604
                       
605
                        
534 606
                    </Canvas>
535 607
                </ControlTemplate>
536 608
            </Setter.Value>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)