コード例 #1
0
                private void EditMode_Begin( )
                {
                    if (EditMode_Enabled == false)
                    {
                        EditMode_Enabled = true;

                        ParentEditingCanvas.Children.Add(EditMode_TextBox);

                        // position and size the textbox
                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox, Frame.Left - 5);
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox, Frame.Top - 2);

                        float availableWidth = ParentSize.Width - Frame.Left;

                        EditMode_TextBox.Width  = availableWidth;
                        EditMode_TextBox.Height = Frame.Height * 1.25f;

                        // get the full text. we can use the build HTML stream code to do this.
                        string htmlStream = string.Empty;
                        string textStream = string.Empty;
                        BuildHTMLContent(ref htmlStream, ref textStream, new List <IUIControl>( ));

                        // if the last character is a URL glyph, remove it
                        textStream = textStream.Trim(new char[] { ' ', PrivateNoteConfig.CitationUrl_Icon[0] });

                        // assign the text
                        EditMode_TextBox.Text = textStream;

                        // and now the URL support
                        EditMode_TextBox_Url.Text = ActiveUrl == null ? EditableConfig.sPlaceholderUrlText : ActiveUrl;
                        ParentEditingCanvas.Children.Add(EditMode_TextBox_Url);
                        EditMode_TextBox_Url.Width  = availableWidth;
                        EditMode_TextBox_Url.Height = 33;

                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox_Url, Frame.Left - 5);
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox_Url, Frame.Bottom + 5);

                        Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate()
                        {
                            EditMode_TextBox.Focus( );
                            Keyboard.Focus(EditMode_TextBox);
                            EditMode_TextBox.CaretIndex = EditMode_TextBox.Text.Length + 1;

                            if (EditMode_TextBox.Text == sDefaultNewParagraphText)
                            {
                                EditMode_TextBox.SelectAll( );
                            }

                            if (EditMode_TextBox_Url.Text == EditableConfig.sPlaceholderUrlText)
                            {
                                EditMode_TextBox_Url.SelectAll( );
                            }
                        }));
                    }
                }
コード例 #2
0
ファイル: EditableHeader.cs プロジェクト: J3057/MobileApp
                private void EditMode_Begin( )
                {
                    if (EditMode_Enabled == false)
                    {
                        EditMode_Enabled = true;

                        ParentEditingCanvas.Children.Add(EditMode_TextBox_Title);
                        ParentEditingCanvas.Children.Add(EditMode_TextBox_Date);
                        ParentEditingCanvas.Children.Add(EditMode_TextBox_Speaker);

                        // hide the regular text
                        mTitle.Hidden   = true;
                        mSpeaker.Hidden = true;
                        mDate.Hidden    = true;

                        // position and size the textboxes
                        float availableWidth = ParentSize.Width - Padding.Left - Padding.Width - (BorderPaddingPx * 2);

                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox_Title, mTitle.Frame.Left);
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox_Title, mTitle.Frame.Top - 10);

                        EditMode_TextBox_Title.Width  = availableWidth;
                        EditMode_TextBox_Title.Height = mTitle.Frame.Height;


                        // date
                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox_Date, mDate.Frame.Left);
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox_Date, mDate.Frame.Top);

                        EditMode_TextBox_Date.Width  = availableWidth / 2;
                        EditMode_TextBox_Date.Height = mDate.Frame.Height + 5;


                        // speaker
                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox_Speaker, mDate.Frame.Left + (availableWidth / 2));
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox_Speaker, mSpeaker.Frame.Top);

                        EditMode_TextBox_Speaker.Width  = availableWidth / 2;
                        EditMode_TextBox_Speaker.Height = mSpeaker.Frame.Height + 5;


                        // assign each text box
                        EditMode_TextBox_Title.Text   = mTitle.Text.Trim(' ');
                        EditMode_TextBox_Speaker.Text = mSpeaker.Text.Trim(' ');
                        EditMode_TextBox_Date.Text    = mDate.Text.Trim(' ');

                        Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate()
                        {
                            EditMode_TextBox_Title.Focus( );
                            Keyboard.Focus(EditMode_TextBox_Title);
                            EditMode_TextBox_Title.CaretIndex = EditMode_TextBox_Title.Text.Length + 1;

                            if (EditMode_TextBox_Title.Text == sDefaultHeaderTitleText)
                            {
                                EditMode_TextBox_Title.SelectAll( );
                                EditMode_TextBox_Date.SelectAll( );
                                EditMode_TextBox_Speaker.SelectAll( );
                            }
                        }));
                    }
                }
コード例 #3
0
                private void EditMode_Begin( )
                {
                    if (EditMode_Enabled == false)
                    {
                        EditMode_Enabled = true;

                        // hide the normal controls
                        QuoteLabel.Hidden = true;
                        Citation.Hidden   = true;
                        BorderView.Hidden = true;
                        UrlGlyph.Hidden   = true;

                        ParentEditingCanvas.Children.Add(EditMode_TextBox_Quote);
                        ParentEditingCanvas.Children.Add(EditMode_TextBox_Citation);

                        // first get the size of the control, which should be whatever's largest: the quote or citation.
                        // we do this to prevent taking a 0 width, which it could be if the quote or citation are blank.
                        float controlWidth  = Math.Max(QuoteLabel.Frame.Width, Citation.Frame.Width);
                        float controlHeight = Math.Max(QuoteLabel.Frame.Height, Citation.Frame.Height);


                        // position and size the textboxes
                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox_Quote, QuoteLabel.Frame.Left);
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox_Quote, QuoteLabel.Frame.Top);

                        float availWidth = Math.Min((ParentSize.Width - QuoteLabel.Frame.Left), controlWidth * 4);

                        EditMode_TextBox_Quote.Width  = availWidth;
                        EditMode_TextBox_Quote.Height = 128;

                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox_Citation, QuoteLabel.Frame.Left);
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox_Citation, QuoteLabel.Frame.Top + EditMode_TextBox_Quote.Height);

                        EditMode_TextBox_Citation.Width  = availWidth;
                        EditMode_TextBox_Citation.Height = Citation.Frame.Height;

                        // assign each text box
                        EditMode_TextBox_Quote.Text    = QuoteLabel.Text.Trim(' ');
                        EditMode_TextBox_Citation.Text = Citation.Text.Trim(' ');


                        // and now the URL support
                        EditMode_TextBox_Url.Text = ActiveUrl == null ? EditableConfig.sPlaceholderUrlText : ActiveUrl;
                        ParentEditingCanvas.Children.Add(EditMode_TextBox_Url);
                        EditMode_TextBox_Url.Width  = availWidth;
                        EditMode_TextBox_Url.Height = 33;
                        System.Windows.Controls.Canvas.SetLeft(EditMode_TextBox_Url, QuoteLabel.Frame.Left);
                        System.Windows.Controls.Canvas.SetTop(EditMode_TextBox_Url, QuoteLabel.Frame.Top + EditMode_TextBox_Quote.Height + EditMode_TextBox_Citation.Height + 5);


                        Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate()
                        {
                            EditMode_TextBox_Quote.Focus( );
                            Keyboard.Focus(EditMode_TextBox_Quote);
                            EditMode_TextBox_Quote.CaretIndex = EditMode_TextBox_Quote.Text.Length + 1;

                            if (EditMode_TextBox_Quote.Text == sDefaultNewQuoteText)
                            {
                                EditMode_TextBox_Quote.SelectAll( );
                                EditMode_TextBox_Citation.SelectAll( );
                            }

                            if (EditMode_TextBox_Url.Text == EditableConfig.sPlaceholderUrlText)
                            {
                                EditMode_TextBox_Url.SelectAll( );
                            }
                        }));
                    }
                }