Пример #1
0
 private void delete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("هل أنت متأكد من الحذف", "حذف", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
     {
         if (id.Text != string.Empty && Cus_id.Text != string.Empty && priceText.Text != string.Empty)
         {
             try
             {
                 pro.DeleteMoney(Convert.ToInt32(id.Text), Convert.ToInt32(Cus_id.Text), Convert.ToDouble(priceText.Text));
                 MessageBox.Show("تم الحذف بنجاح", "حذف", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Cus_id.Clear();
                 id.Clear();
                 priceText.Clear();
                 order_id.Clear();
                 ClientName.Clear();
                 NoteText.Clear();
                 date.Value = DateTime.Now;
                 position   = pro.ShowAllGetMoney().Rows.Count - 1;
                 Navigate(position);
             }
             catch
             {
                 return;
             }
         }
         else
         {
             MessageBox.Show("خطأ! لايوجد بيانات لحذفها", "حذف", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 protected void OrderNotesGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("AddNote"))
     {
         string[] data    = ((string)e.CommandArgument).Split(':');
         int      orderId = AlwaysConvert.ToInt(data[0]);
         HiddenOrderId.Value   = orderId.ToString();
         AddDialogCaption.Text = String.Format(AddDialogCaption.Text, data[1]);
         List <string> history = new List <string>();
         Order         order   = EntityLoader.Load <Order>(orderId);
         if (order != null)
         {
             IList <OrderNote> notes = order.Notes;
             notes.Sort(new PropertyComparer("CreatedDate", CommerceBuilder.Common.SortDirection.DESC));
             foreach (OrderNote note in notes)
             {
                 if (note.NoteType != NoteType.SystemPrivate && note.NoteType != NoteType.SystemPublic)
                 {
                     StringBuilder historyEntry = new StringBuilder();
                     historyEntry.Append("<i>On " + note.CreatedDate.ToString("g") + ", ");
                     historyEntry.Append(note.User.PrimaryAddress.FullName);
                     historyEntry.Append(note.NoteType == NoteType.Public ? " wrote" : " whispered");
                     historyEntry.Append(":</i><br />");
                     historyEntry.Append(note.Comment);
                     history.Add(historyEntry.ToString());
                 }
             }
         }
         NoteHistory.Text = string.Join("<hr>", history.ToArray());
         AddPopup.Show();
         NoteText.Focus();
     }
 }
Пример #3
0
        private void FindAndChange_OnClick(object sender, RoutedEventArgs e)
        {
            NoteText.Focus();
            NoteText.SelectionStart = 0;

            finder = new Find_and_Change(this);
            finder.Show();
        }
Пример #4
0
        private void SaveButtonFunc_Click(object sender, RoutedEventArgs e)
        {
            string[] InputStrings = File.ReadAllLines(@"../../Information.txt");

            List <Person> people = new List <Person>();

            for (int i = 0; i < InputStrings.Length; i += 6)
            {
                people.Add(new Person(InputStrings[i], InputStrings[i + 1], InputStrings[i + 2], int.Parse(InputStrings[i + 3]), InputStrings[i + 4], InputStrings[i + 5]));
            }
            StreamWriter NoteFile = new StreamWriter(@"../../Information.txt", append: true);

            try
            {
                string[] inputtext = NoteText.Text.Split('\n');
                int      i         = 2;
                int      n;
                while (!int.TryParse(inputtext[i], out n))
                {
                    i++;
                }
                List <string> equtions = new List <string>();
                int           k        = 0;
                for (int j = i + 1; j < inputtext.Length; j++)
                {
                    if (inputtext[j].Contains("=") && (inputtext[j].Contains("-") || inputtext[j].Contains("+")))
                    {
                        equtions.Add(inputtext[j]);
                        k++;
                    }
                    if (k >= 2)
                    {
                        break;
                    }
                }
                Person p = new Person(inputtext[0], inputtext[1], inputtext[2], n, equtions[0], equtions[1]);
                if (!people.Contains(p))
                {
                    NoteFile.Write(p.FirstName);
                    NoteFile.Write(p.LastName);
                    NoteFile.Write(p.City);
                    NoteFile.WriteLine(p.Age);
                    NoteFile.Write(p.Equation1);
                    NoteFile.Write(p.Equation2);
                }
            }
            catch { }



            NoteFile.Close();
            NoteText.Clear();
        }
Пример #5
0
        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var addedItems = e.AddedItems;

            if (addedItems.Count > 0)
            {
                NoteText.Text = NotesDL.GetInstance.GetNote(((Note)addedItems[0]).Id).Text;
            }
            RenderMarkDown(NoteText.Text);
            NoteText.Focus();
            NoteText.SelectionStart = NoteText.Text.Length;
        }
Пример #6
0
 private void ChoseCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ChoseCategory.SelectedIndex != -1)
     {
         Resources["Notes"] = NotesDL.GetInstance.GetNoteInCategorylist(Application.Current.Properties["UserName"].ToString(), ((Category)ChoseCategory.Items[ChoseCategory.SelectedIndex]).Id);
         if (!NotesList.Items.IsEmpty)
         {
             NotesList.SelectedIndex = 0;
         }
     }
     RenderMarkDown(NoteText.Text);
     NoteText.Focus();
     NoteText.SelectionStart = NoteText.Text.Length;
 }
Пример #7
0
                // Takes a string and replaces the content of the paragraph with it.
                private void SetText(string text, string activeUrl)
                {
                    foreach (IUIControl control in ChildControls)
                    {
                        control.RemoveFromView(ParentEditingCanvas);
                    }
                    ChildControls.Clear( );

                    // give the text a style that doesn't include things it shouldn't inherit
                    Styles.Style textStyle = mStyle;
                    textStyle.mBorderColor  = null;
                    textStyle.mBorderRadius = null;
                    textStyle.mBorderWidth  = null;

                    // now break it into words so we can do word wrapping
                    string[] words = text.Split(' ');

                    foreach (string word in words)
                    {
                        // create labels out of each one
                        if (string.IsNullOrEmpty(word) == false)
                        {
                            // if the last thing we added was a special control like a reveal box, we
                            // need the first label after that to have a leading space so it doesn't bunch up against
                            // the control
                            string   nextWord  = word;
                            NoteText wordLabel = Parser.CreateNoteText(new CreateParams(this, Frame.Width, Frame.Height, ref textStyle), nextWord + " ");

                            ChildControls.Add(wordLabel);
                        }
                    }

                    if (activeUrl.Trim( ) != EditableConfig.sPlaceholderUrlText && string.IsNullOrWhiteSpace(activeUrl) == false)
                    {
                        // help them out by adding 'https://' if it isn't there.
                        if (activeUrl.StartsWith("https") == false && BibleRenderer.IsBiblePrefix(activeUrl) == false)
                        {
                            activeUrl = activeUrl.Insert(0, "https://");
                        }

                        ActiveUrl = activeUrl;
                    }
                    else
                    {
                        ActiveUrl = null;
                    }

                    TryAddUrlGlyph(Frame.Width, Frame.Height);
                }
Пример #8
0
        private void button3_Click(object sender, EventArgs e)
        {
            newbtn.Enabled      = false;
            edit.Enabled        = false;
            delete.Enabled      = false;
            choosCust.Enabled   = false;
            chooseOrder.Enabled = false;
            priceText.Enabled   = true;
            date.Enabled        = true;
            NoteText.Enabled    = true;
            save.Enabled        = true;
            status = "edit";

            prevPrice = Convert.ToDouble(priceText.Text);
            NoteText.Focus();
        }
Пример #9
0
                public void TryAddUrlGlyph(float parentWidth, float parentHeight)
                {
                    if (string.IsNullOrEmpty(ActiveUrl) == false)
                    {
                        // give the text a style that doesn't include things it shouldn't inherit
                        Styles.Style textStyle = mStyle;
                        textStyle.mBorderColor  = 0;
                        textStyle.mBorderRadius = 0;
                        textStyle.mBorderWidth  = 0;
                        textStyle.mFont.mColor  = mStyle.mFont.mColor ?? ControlStyles.mText.mFont.mColor;
                        textStyle.mFont.mName   = PrivateControlStylingConfig.Icon_Font_Secondary;
                        textStyle.mFont.mSize   = mStyle.mFont.mSize ?? ControlStyles.mText.mFont.mSize;
                        textStyle.mAlignment    = Alignment.Right;

                        NoteText wordLabel = Parser.CreateNoteText(new CreateParams(this, parentWidth, parentHeight, ref textStyle), PrivateNoteConfig.CitationUrl_Icon);
                        ChildControls.Add(wordLabel);
                    }
                }
Пример #10
0
        public void Update()
        {
            var newText = NoteText?.Trim();

            Check.DoCheckOperationValid(!string.IsNullOrEmpty(newText), () => "Note text must not be empty.");

            if (Note == null)
            {
                Note = ReadFromStorage();
            }

            if (Note.Text != newText)
            {
                Note.Text           = newText;
                Note.LastUpdateTime = DateTime.Now;

                NoteStorage.SaveOrUpdate(Note);
            }
        }
Пример #11
0
        private void button4_Click(object sender, EventArgs e)
        {
            newbtn.Enabled      = false;
            edit.Enabled        = false;
            delete.Enabled      = false;
            choosCust.Enabled   = true;
            chooseOrder.Enabled = true;
            priceText.Enabled   = true;
            date.Enabled        = true;
            NoteText.Enabled    = true;
            save.Enabled        = true;
            status = "add";
            int ids = Convert.ToInt32(pro.GetMoneyLastId().Rows[0][0].ToString());

            Cus_id.Clear();
            priceText.Clear();
            order_id.Clear();
            ClientName.Clear();
            NoteText.Clear();
            date.Value = DateTime.Now;
            id.Text    = ids.ToString();
            id.Focus();
        }
Пример #12
0
        private void ShowButtonFunc_Click(object sender, RoutedEventArgs e)
        {
            NoteText.Clear();
            string[] InputStrings = File.ReadAllLines(@"../../Information.txt");

            List <Person> people = new List <Person>();

            for (int i = 0; i < InputStrings.Length; i += 6)
            {
                people.Add(new Person(InputStrings[i], InputStrings[i + 1], InputStrings[i + 2], int.Parse(InputStrings[i + 3]), InputStrings[i + 4], InputStrings[i + 5]));
            }
            for (int i = 0; i < people.Count; i++)
            {
                NoteText.Text += $"Person {i+1} :\n";
                NoteText.Text += $"  First Name : {people[i].FirstName}\n";
                NoteText.Text += $"  Last Name : { people[i].LastName}\n";
                NoteText.Text += $"  City : {people[i].City}\n";
                NoteText.Text += $"  Age : {people[i].Age}\n";
                NoteText.Text += $"  Equation 1 : {people[i].Equation1}\n";
                NoteText.Text += $"  Equation 2 : {people[i].Equation2}\n";
                NoteText.Text += $"  Answers : {people[i].Answers[0].ch} = {people[i].Answers[0].answer}" +
                                 $" , {people[i].Answers[1].ch} = {people[i].Answers[1].answer}\n";
            }
        }
Пример #13
0
                public ListItem( CreateParams parentParams, XmlReader reader )
                {
                    // verify that our parent is a list. That's the only acceptable place for us.
                    if( (parentParams.Parent as List) == null )
                    {
                        throw new Exception( string.Format( "<ListItem> parent must be <List>. This <ListItem> parent is: <{0}>", parentParams.Parent.GetType() ) );
                    }

                    Initialize( );

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults( reader, ref mStyle, ref ControlStyles.mListItem );
                    mStyle.mAlignment = null; //don't use alignment

                    // check for attributes we support
                    RectangleF bounds = new RectangleF( );
                    SizeF parentSize = new SizeF( parentParams.Width, parentParams.Height );
                    ParseCommonAttribs( reader, ref parentSize, ref bounds );

                    //ignore positioning attributes.
                    bounds = new RectangleF( );
                    bounds.Width = parentParams.Width;

                    // Get margins and padding
                    RectangleF padding;
                    RectangleF margin;
                    GetMarginsAndPadding( ref mStyle, ref parentSize, ref bounds, out margin, out padding );

                    // apply margins to as much of the bounds as we can (bottom must be done by our parent container)
                    ApplyImmediateMargins( ref bounds, ref margin, ref parentSize );
                    Margin = margin;

                    // check for border styling
                    int borderPaddingPx = 0;
                    if ( mStyle.mBorderColor.HasValue )
                    {
                        BorderView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if( mStyle.mBorderRadius.HasValue )
                    {
                        BorderView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if( mStyle.mBorderWidth.HasValue )
                    {
                        BorderView.BorderWidth = mStyle.mBorderWidth.Value;
                        borderPaddingPx = (int)Rock.Mobile.Graphics.Util.UnitToPx( mStyle.mBorderWidth.Value + PrivateNoteConfig.BorderPadding );
                    }

                    if( mStyle.mBackgroundColor.HasValue )
                    {
                        BorderView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }
                    //

                    // now calculate the available width based on padding. (Don't actually change our width)
                    float availableWidth = bounds.Width - padding.Left - padding.Width - (borderPaddingPx * 2);

                    // Parse Child Controls
                    bool finishedParsing = false;
                    while( finishedParsing == false && reader.Read( ) )
                    {
                        switch( reader.NodeType )
                        {
                            case XmlNodeType.Element:
                            {
                                // let each child have our available width.
                                IUIControl control = Parser.TryParseControl( new CreateParams( this, availableWidth, parentParams.Height, ref mStyle ), reader );
                                if( control != null )
                                {
                                    ChildControls.Add( control );
                                }
                                break;
                            }

                            case XmlNodeType.Text:
                            {
                                // grab the text. remove any weird characters
                                string text = Regex.Replace( reader.Value, @"\t|\n|\r", "" );

                                // now break it into words so we can do word wrapping
                                string[] words = text.Split( ' ' );

                                // the very very first word gets a bullet point!
                                string sentence = "";
                                foreach( string word in words )
                                {
                                    // create labels out of each one
                                    if( string.IsNullOrEmpty( word ) == false )
                                    {
                                        sentence += word + " ";
                                    }
                                }

                                NoteText textLabel = new NoteText( new CreateParams( this, availableWidth, parentParams.Height, ref mStyle ), sentence );
                                ChildControls.Add( textLabel );
                                break;
                            }

                            case XmlNodeType.EndElement:
                            {
                                // if we hit the end of our label, we're done.
                                //if( reader.Name == "ListItem" || reader.Name == "LI" )
                                if( ElementTagMatches( reader.Name ) )
                                {
                                    finishedParsing = true;
                                }

                                break;
                            }
                        }
                    }

                    LayoutStackPanel( bounds, padding.Left, padding.Top, availableWidth, padding.Height, borderPaddingPx );
                }
Пример #14
0
                public Paragraph( CreateParams parentParams, XmlReader reader )
                {
                    Initialize( );

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults( reader, ref mStyle, ref ControlStyles.mParagraph );

                    // check for attributes we support
                    RectangleF bounds = new RectangleF( );
                    SizeF parentSize = new SizeF( parentParams.Width, parentParams.Height );
                    ParseCommonAttribs( reader, ref parentSize, ref bounds );

                    // Get margins and padding
                    RectangleF padding;
                    RectangleF margin;
                    GetMarginsAndPadding( ref mStyle, ref parentSize, ref bounds, out margin, out padding );

                    // apply margins to as much of the bounds as we can (bottom must be done by our parent container)
                    ApplyImmediateMargins( ref bounds, ref margin, ref parentSize );
                    Margin = margin;

                    // check for border styling
                    int borderPaddingPx = 0;
                    if ( mStyle.mBorderColor.HasValue )
                    {
                        BorderView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if( mStyle.mBorderRadius.HasValue )
                    {
                        BorderView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if( mStyle.mBorderWidth.HasValue )
                    {
                        BorderView.BorderWidth = mStyle.mBorderWidth.Value;
                        borderPaddingPx = (int)Rock.Mobile.Graphics.Util.UnitToPx( mStyle.mBorderWidth.Value + PrivateNoteConfig.BorderPadding );
                    }

                    if( mStyle.mBackgroundColor.HasValue )
                    {
                        BorderView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }
                    //

                    // now calculate the available width based on padding. (Don't actually change our width)
                    float availableWidth = bounds.Width - padding.Left - padding.Width - (borderPaddingPx * 2);

                    // see if there's a URL we should care about
                    ActiveUrl = reader.GetAttribute( "Url" );

                    string urlLaunchesExternalBrowser = reader.GetAttribute( "UrlLaunchesExternalBrowser" );
                    if ( string.IsNullOrEmpty( urlLaunchesExternalBrowser ) == false )
                    {
                        UrlLaunchesExternalBrowser = bool.Parse( urlLaunchesExternalBrowser );
                    }

                    string urlUsesRockImpersonation = reader.GetAttribute( "UrlUsesRockImpersonation" );
                    if ( string.IsNullOrEmpty( urlUsesRockImpersonation ) == false )
                    {
                        UrlUsesRockImpersonation = bool.Parse( urlUsesRockImpersonation );
                    }

                    // now read what our children's alignment should be
                    // check for alignment
                    string result = reader.GetAttribute( "ChildAlignment" );
                    if( string.IsNullOrEmpty( result ) == false )
                    {
                        switch( result )
                        {
                            case "Left":
                            {
                                ChildHorzAlignment = Alignment.Left;
                                break;
                            }
                            case "Right":
                            {
                                ChildHorzAlignment = Alignment.Right;
                                break;
                            }
                            case "Center":
                            {
                                ChildHorzAlignment = Alignment.Center;
                                break;
                            }
                            default:
                            {
                                ChildHorzAlignment = mStyle.mAlignment.Value;
                                break;
                            }
                        }
                    }
                    else
                    {
                        // if it wasn't specified, use LEFT alignment.
                        ChildHorzAlignment = Alignment.Left;
                    }

                    bool removedLeadingWhitespace = false;
                    bool lastControlWasElement = false;

                    bool finishedReading = false;
                    while( finishedReading == false && reader.Read( ) )
                    {
                        switch( reader.NodeType )
                        {
                            case XmlNodeType.Element:
                            {
                                IUIControl control = Parser.TryParseControl( new CreateParams( this, availableWidth, parentParams.Height, ref mStyle ), reader );
                                if ( control != null )
                                {
                                    // if the last control was an element (NoteText or Reveal), then we have two in a row. So place a space between them!
                                    if ( lastControlWasElement )
                                    {
                                        NoteText textLabel = new NoteText( new CreateParams( this, availableWidth, parentParams.Height, ref mStyle ), " " );
                                        ChildControls.Add( textLabel );
                                    }

                                    // only allow RevealBoxes / NoteText as children.
                                    if ( control as RevealBox == null && control as NoteText == null )
                                    {
                                        throw new Exception( String.Format( "Paragraph only supports children of type <RevealBox> or <NoteText>. Found <{0}>", control.GetType( ) ) );
                                    }
                                    ChildControls.Add( control );

                                    // flag that whitespace is removed, because either
                                    // this was the first control and we didn't want to, or
                                    // it was removed by the first text we created.
                                    removedLeadingWhitespace = true;

                                    // flag that the last control placed was a reveal, so that
                                    // should we come across another one immediately, we know to insert a space
                                    // so they don't render concatenated.
                                    lastControlWasElement = true;
                                }
                                break;
                            }

                            case XmlNodeType.Text:
                            {
                                // give the text a style that doesn't include things it shouldn't inherit
                                Styles.Style textStyle = mStyle;
                                textStyle.mBorderColor = null;
                                textStyle.mBorderRadius = null;
                                textStyle.mBorderWidth = null;

                                // grab the text. remove any weird characters
                                string text = Regex.Replace( reader.Value, @"\t|\n|\r", "" );

                                if( removedLeadingWhitespace == false )
                                {
                                    removedLeadingWhitespace = true;
                                    text = text.TrimStart( ' ' );
                                }

                                // now break it into words so we can do word wrapping
                                string[] words = text.Split( ' ' );
                                foreach( string word in words )
                                {
                                    // create labels out of each one
                                    if( string.IsNullOrEmpty( word ) == false )
                                    {
                                        // if the last thing we added was a special control like a reveal box, we 
                                        // need the first label after that to have a leading space so it doesn't bunch up against
                                        // the control
                                        string nextWord = word;
                                        if( lastControlWasElement )
                                        {
                                            nextWord = word.Insert(0, " ");
                                            lastControlWasElement = false;
                                        }

                                        NoteText wordLabel = new NoteText( new CreateParams( this, availableWidth, parentParams.Height, ref textStyle ), nextWord + " " );

                                        ChildControls.Add( wordLabel );
                                    }
                                }

                                lastControlWasElement = false;

                                break;
                            }

                            case XmlNodeType.EndElement:
                            {
                                // if we hit the end of our label, we're done.
                                //if( reader.Name == "Paragraph" || reader.Name == "P" )
                                if( ElementTagMatches( reader.Name ) )
                                {
                                    finishedReading = true;
                                }
                                break;
                            }
                        }
                    }

                    // should we add a URL Glyph? We're gonna be clever and add it AS a NoteText, so that it integrates with the paragraph nicely.
                    // now add our glyph, if relevant
                    if ( string.IsNullOrEmpty( ActiveUrl ) == false )
                    {
                        // give the text a style that doesn't include things it shouldn't inherit
                        Styles.Style textStyle = mStyle;
                        textStyle.mBorderColor = 0;
                        textStyle.mBorderRadius = 0;
                        textStyle.mBorderWidth = 0;
                        textStyle.mFont.mColor = NoteConfig.CitationUrl_IconColor;
                        textStyle.mFont.mName = PrivateControlStylingConfig.Icon_Font_Secondary;
                        textStyle.mFont.mSize = PrivateNoteConfig.CitationUrl_IconSize;
                        textStyle.mAlignment = Alignment.Right;

                        NoteText wordLabel = new NoteText( new CreateParams( this, availableWidth, parentParams.Height, ref textStyle ), PrivateNoteConfig.CitationUrl_Icon );
                        ChildControls.Add( wordLabel );
                    }


                    // layout all controls
                    // paragraphs are tricky. 
                    // We need to lay out controls horizontally and wrap when we run out of room. 

                    // To align, we need to keep track of each "row". When the row is full,
                    // we calculate its width, and then adjust each item IN that row so
                    // that the row is centered within the max width of the paragraph.
                    // The max width of the paragraph is defined as the widest row.

                    // maintain a list of all our rows so that once they are all generated,
                    // we can align them based on the widest row.
                    float maxRowWidth = 0;
                    List< List<IUIControl> > rowList = new List< List<IUIControl> >( );

                    // track where within a row we need to start a control
                    float rowRemainingWidth = availableWidth;
                    float startingX = bounds.X + padding.Left + borderPaddingPx;

                    // always store the last placed control's height so that should 
                    // our NEXT control need to wrap, we know how far down to wrap.
                    float yOffset = bounds.Y + padding.Top + borderPaddingPx;
                    float lastControlHeight = 0;
                    float rowWidth = 0;

                    //Create our first row and put it in our list
                    List< IUIControl > currentRow = new List<IUIControl>( );
                    rowList.Add( currentRow );

                    foreach( IUIControl control in ChildControls )
                    {
                        RectangleF controlFrame = control.GetFrame( );

                        // if there is NOT enough room on this row for the next control
                        if( rowRemainingWidth < controlFrame.Width )
                        {
                            // since we're advancing to the next row, trim leading white space, which, if we weren't wrapping,
                            // would be a space between words.
                            // note: we can safely cast to a NoteText because that's the only child type we allow.
                            string text = ( (NoteText)control ).GetText( ).TrimStart( ' ' );
                            ( (NoteText)control ).SetText( text );

                            // advance to the next row
                            yOffset += lastControlHeight;

                            // Reset values for the new row
                            rowRemainingWidth = availableWidth;
                            startingX = bounds.X + padding.Left + borderPaddingPx;
                            lastControlHeight = 0;
                            rowWidth = 0;

                            currentRow = new List<IUIControl>( );
                            rowList.Add( currentRow );
                        }

                        // Add this next control to the current row
                        currentRow.Add( control );

                        // position this control appropriately
                        control.AddOffset( startingX, yOffset );

                        // update so the next child begins beyond this one.
                        // also reduce the available width by this control's.
                        rowWidth += controlFrame.Width;
                        startingX += controlFrame.Width; //Increment startingX so the next control is placed after this one.
                        rowRemainingWidth -= controlFrame.Width; //Reduce the available width by what this control took.
                        lastControlHeight = controlFrame.Height > lastControlHeight ? controlFrame.Height : lastControlHeight; //Store the height of the tallest control on this row.

                        // track the widest row
                        maxRowWidth = rowWidth > maxRowWidth ? rowWidth : maxRowWidth;
                    }

                    // give each row the legal bounds it may work with
                    RectangleF availableBounds = new RectangleF( bounds.X + padding.Left + borderPaddingPx, 
                                                                 bounds.Y + borderPaddingPx + padding.Top, 
                                                                 availableWidth, 
                                                                 bounds.Height );

                    // Now that we know the widest row, align all the rows
                    foreach( List<IUIControl> row in rowList )
                    {
                        AlignRow( availableBounds, row, maxRowWidth );
                    }


                    // Build our final frame that determines our dimensions
                    RectangleF frame = new RectangleF( 65000, 65000, -65000, -65000 );

                    // for each child control
                    foreach( IUIControl control in ChildControls )
                    {
                        // enlarge our frame by the current frame and the next child
                        frame = Parser.CalcBoundingFrame( frame, control.GetFrame( ) );
                    }

                    frame.Y = bounds.Y;
                    frame.X = bounds.X;
                    frame.Height += padding.Height + padding.Top + (borderPaddingPx * 2); //add in padding
                    frame.Width = bounds.Width;

                    // setup our bounding rect for the border
                    frame = new RectangleF( frame.X, 
                                            frame.Y,
                                            frame.Width, 
                                            frame.Height );

                    // and store that as our bounds
                    BorderView.Frame = frame;

                    Frame = frame;
                    SetDebugFrame( Frame );

                    // sort everything
                    ChildControls.Sort( BaseControl.Sort );
                }
Пример #15
0
                public List( CreateParams parentParams, XmlReader reader )
                {
                    Initialize( );

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults( reader, ref mStyle, ref ControlStyles.mList );

                    // check for attributes we support
                    RectangleF bounds = new RectangleF( );
                    SizeF parentSize = new SizeF( parentParams.Width, parentParams.Height );
                    ParseCommonAttribs( reader, ref parentSize, ref bounds );

                    // Get margins and padding
                    RectangleF padding;
                    RectangleF margin;
                    GetMarginsAndPadding( ref mStyle, ref parentSize, ref bounds, out margin, out padding );

                    // apply margins to as much of the bounds as we can (bottom must be done by our parent container)
                    ApplyImmediateMargins( ref bounds, ref margin, ref parentSize );
                    Margin = margin;

                    // check for border styling
                    int borderPaddingPx = 0;
                    if ( mStyle.mBorderColor.HasValue )
                    {
                        BorderView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if( mStyle.mBorderRadius.HasValue )
                    {
                        BorderView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if( mStyle.mBorderWidth.HasValue )
                    {
                        BorderView.BorderWidth = mStyle.mBorderWidth.Value;
                        borderPaddingPx = (int)Rock.Mobile.Graphics.Util.UnitToPx( mStyle.mBorderWidth.Value + PrivateNoteConfig.BorderPadding );
                    }

                    if( mStyle.mBackgroundColor.HasValue )
                    {
                        BorderView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }
                    //

                    // convert indentation if it's a percentage
                    float listIndentation = mStyle.mListIndention.Value;
                    if( listIndentation < 1 )
                    {
                        listIndentation = parentParams.Width * listIndentation;
                    }

                    // now calculate the available width based on padding. (Don't actually change our width)
                    // also consider the indention amount of the list.
                    float availableWidth = bounds.Width - padding.Left - padding.Width - listIndentation - (borderPaddingPx * 2);


                    // parse for the desired list style. Default to Bullet if they didn't put anything.
                    ListType = reader.GetAttribute( "Type" );
                    if( string.IsNullOrEmpty( ListType ) == true)
                    {
                        ListType = ListTypeBullet;
                    }

                    // Parse Child Controls
                    int numberedCount = 1;

                    // don't force our alignment, borders, bullet style or indentation on children.
                    Style style = new Style( );
                    style = mStyle;
                    style.mAlignment = null;
                    style.mListIndention = null;
                    style.mListBullet = null;
                    style.mBorderColor = null;
                    style.mBorderRadius = null;
                    style.mBorderWidth = null;

                    bool finishedParsing = false;
                    while( finishedParsing == false && reader.Read( ) )
                    {
                        switch( reader.NodeType )
                        {
                            case XmlNodeType.Element:
                            {
                                // Create the prefix for this list item.
                                string listItemPrefixStr = mStyle.mListBullet + " ";
                                if( ListType == ListTypeNumbered )
                                {
                                    listItemPrefixStr = numberedCount.ToString() + ". ";
                                }

                                NoteText textLabel = new NoteText( new CreateParams( this, availableWidth, parentParams.Height, ref style ), listItemPrefixStr );
                                ChildControls.Add( textLabel );


                                // create our actual child, but throw an exception if it's anything but a ListItem.
                                IUIControl control = Parser.TryParseControl( new CreateParams( this, availableWidth - textLabel.GetFrame().Width, parentParams.Height, ref style ), reader );

                                ListItem listItem = control as ListItem;
                                if( listItem == null ) throw new Exception( String.Format("Only a <ListItem> may be a child of a <List>. Found element <{0}>.", control.GetType( ) ) );


                                // if it will actually use the bullet point, increment our count.
                                if( listItem.ShouldShowBulletPoint() == true )
                                {
                                    numberedCount++;
                                }
                                else
                                {
                                    // otherwise give it a blank space, and keep our count the same.
                                    textLabel.SetText("  ");
                                }

                                // and finally add the actual list item.
                                ChildControls.Add( control );
                                break;
                            }

                            case XmlNodeType.EndElement:
                            {
                                // if we hit the end of our label, we're done.
                                //if( reader.Name == "List" || reader.Name == "L" )
                                if( ElementTagMatches( reader.Name ) )
                                {
                                    finishedParsing = true;
                                }

                                break;
                            }
                        }
                    }


                    // layout all controls
                    float xAdjust = bounds.X + listIndentation; 
                    float yOffset = bounds.Y + padding.Top + borderPaddingPx; //vertically they should just stack

                    // we know each child is a NoteText followed by ListItem. So, lay them out 
                    // as: * - ListItem
                    //     * - ListItem
                    foreach( IUIControl control in ChildControls )
                    {
                        // position the control
                        control.AddOffset( xAdjust + padding.Left + borderPaddingPx, yOffset );

                        RectangleF controlFrame = control.GetFrame( );
                        RectangleF controlMargin = control.GetMargin( );

                        // is this the item prefix?
                        if( (control as NoteText) != null )
                        {
                            // and update xAdjust so the actual item starts after.
                            xAdjust += controlFrame.Width;
                        }
                        else
                        {
                            // reset the values for the next line.
                            xAdjust = bounds.X + listIndentation;
                            yOffset = controlFrame.Bottom + controlMargin.Height;
                        }
                    }

                    // we need to store our bounds. We cannot
                    // calculate them on the fly because we
                    // would lose any control defined offsets, which would throw everything off.
                    bounds.Height = ( yOffset - bounds.Y ) + padding.Height + borderPaddingPx;
                    Bounds = bounds;

                    BorderView.Frame = bounds;

                    // store our debug frame
                    SetDebugFrame( Bounds );

                    // sort everything
                    ChildControls.Sort( BaseControl.Sort );
                }
Пример #16
0
                public void HandleChildStyleChanged(EditStyling.Style style, IEditableUIControl childControl)
                {
                    switch (style)
                    {
                    case EditStyling.Style.RevealBox:
                    {
                        // first, find the target in our list
                        int targetIndex = 0;
                        foreach (IUIControl child in ChildControls)
                        {
                            // when we find it
                            if (child.Equals(childControl) == true)
                            {
                                // take its index, and remove it from the renderer and our list of children
                                targetIndex = ChildControls.IndexOf(child);

                                child.RemoveFromView(ParentEditingCanvas);
                                ChildControls.RemoveAt(targetIndex);
                                break;
                            }
                        }

                        // if we received RevealBox, we're either upgrading a NoteText to BE a RevealBox,
                        // or downgrading a RevealBox to be a normal NoteText.
                        EditableNoteText editableNoteText = childControl as EditableNoteText;
                        if (editableNoteText != null)
                        {
                            // create a new revealBox, but force the text to uppper-case and add the bold font (since this is typically what the Mobile App does)
                            Style controlStyle = childControl.GetControlStyle( );
                            controlStyle.mFont       = new FontParams( );
                            controlStyle.mFont.mName = sDefaultBoldFontName;

                            RevealBox newRevealBox = Parser.CreateRevealBox(new CreateParams(this, Frame.Width, Frame.Height, ref controlStyle), editableNoteText.GetText( ).ToUpper( ).Trim( ));
                            newRevealBox.AddToView(ParentEditingCanvas);

                            // add the new revealBox into the same spot as what it's replacing
                            ChildControls.Insert(targetIndex, newRevealBox);

                            // make sure we add a space after the reveal box, as that's required.
                            NoteText textLabel = Parser.CreateNoteText(new CreateParams(this, Frame.Width, Frame.Height, ref mStyle), " ");
                            textLabel.AddToView(ParentEditingCanvas);
                            ChildControls.Insert(targetIndex + 1, textLabel);
                        }

                        EditableRevealBox editableRevealBox = childControl as EditableRevealBox;
                        if (editableRevealBox != null)
                        {
                            // create a new revealBox that has the styling and text of the noteText it's replacing.
                            Style    controlStyle = childControl.GetControlStyle( );
                            NoteText newNoteText  = Parser.CreateNoteText(new CreateParams(this, Frame.Width, Frame.Height, ref controlStyle), editableRevealBox.GetText( ).Trim( ));
                            newNoteText.AddToView(ParentEditingCanvas);

                            // add the new revealBox into the same spot as what it's replacing
                            ChildControls.Insert(targetIndex, newNoteText);
                        }

                        break;
                    }
                    }

                    // for now, lets just redo our layout.
                    SetPosition(Frame.Left, Frame.Top);
                }
Пример #17
0
                public Paragraph(CreateParams parentParams, XmlReader reader)
                {
                    Initialize( );

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults(reader, ref mStyle, ref ControlStyles.mParagraph);

                    // check for attributes we support
                    RectangleF bounds     = new RectangleF( );
                    SizeF      parentSize = new SizeF(parentParams.Width, parentParams.Height);

                    ParseCommonAttribs(reader, ref parentSize, ref bounds);

                    // Get margins and padding
                    RectangleF padding;
                    RectangleF margin;

                    GetMarginsAndPadding(ref mStyle, ref parentSize, ref bounds, out margin, out padding);

                    // apply margins to as much of the bounds as we can (bottom must be done by our parent container)
                    ApplyImmediateMargins(ref bounds, ref margin, ref parentSize);
                    Margin = margin;

                    // check for border styling
                    int borderPaddingPx = 0;

                    if (mStyle.mBorderColor.HasValue)
                    {
                        BorderView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if (mStyle.mBorderRadius.HasValue)
                    {
                        BorderView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if (mStyle.mBorderWidth.HasValue)
                    {
                        BorderView.BorderWidth = mStyle.mBorderWidth.Value;
                        borderPaddingPx        = (int)Rock.Mobile.Graphics.Util.UnitToPx(mStyle.mBorderWidth.Value + PrivateNoteConfig.BorderPadding);
                    }

                    if (mStyle.mBackgroundColor.HasValue)
                    {
                        BorderView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }
                    //

                    // now calculate the available width based on padding. (Don't actually change our width)
                    float availableWidth = bounds.Width - padding.Left - padding.Width - (borderPaddingPx * 2);

                    // see if there's a URL we should care about
                    ActiveUrl = reader.GetAttribute("Url");

                    string urlLaunchesExternalBrowser = reader.GetAttribute("UrlLaunchesExternalBrowser");

                    if (string.IsNullOrEmpty(urlLaunchesExternalBrowser) == false)
                    {
                        UrlLaunchesExternalBrowser = bool.Parse(urlLaunchesExternalBrowser);
                    }

                    string urlUsesRockImpersonation = reader.GetAttribute("UrlUsesRockImpersonation");

                    if (string.IsNullOrEmpty(urlUsesRockImpersonation) == false)
                    {
                        UrlUsesRockImpersonation = bool.Parse(urlUsesRockImpersonation);
                    }

                    // now read what our children's alignment should be
                    // check for alignment
                    string result = reader.GetAttribute("ChildAlignment");

                    if (string.IsNullOrEmpty(result) == false)
                    {
                        switch (result)
                        {
                        case "Left":
                        {
                            ChildHorzAlignment = Alignment.Left;
                            break;
                        }

                        case "Right":
                        {
                            ChildHorzAlignment = Alignment.Right;
                            break;
                        }

                        case "Center":
                        {
                            ChildHorzAlignment = Alignment.Center;
                            break;
                        }

                        default:
                        {
                            ChildHorzAlignment = mStyle.mAlignment.Value;
                            break;
                        }
                        }
                    }
                    else
                    {
                        // if it wasn't specified, use LEFT alignment.
                        ChildHorzAlignment = Alignment.Left;
                    }

                    bool removedLeadingWhitespace = false;
                    bool lastControlWasElement    = false;

                    bool finishedReading = false;

                    while (finishedReading == false && reader.Read( ))
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                        {
                            IUIControl control = Parser.TryParseControl(new CreateParams(this, availableWidth, parentParams.Height, ref mStyle), reader);
                            if (control != null)
                            {
                                // if the last control was an element (NoteText or Reveal), then we have two in a row. So place a space between them!
                                if (lastControlWasElement)
                                {
                                    NoteText textLabel = Parser.CreateNoteText(new CreateParams(this, availableWidth, parentParams.Height, ref mStyle), " ");
                                    ChildControls.Add(textLabel);
                                }

                                // only allow RevealBoxes / NoteText as children.
                                if (control as RevealBox == null && control as NoteText == null)
                                {
                                    throw new Exception(String.Format("Paragraph only supports children of type <RevealBox> or <NoteText>. Found <{0}>", control.GetType( )));
                                }
                                ChildControls.Add(control);

                                // flag that whitespace is removed, because either
                                // this was the first control and we didn't want to, or
                                // it was removed by the first text we created.
                                removedLeadingWhitespace = true;

                                // flag that the last control placed was a reveal, so that
                                // should we come across another one immediately, we know to insert a space
                                // so they don't render concatenated.
                                lastControlWasElement = true;
                            }
                            break;
                        }

                        case XmlNodeType.Text:
                        {
                            // give the text a style that doesn't include things it shouldn't inherit
                            Styles.Style textStyle = mStyle;
                            textStyle.mBorderColor  = null;
                            textStyle.mBorderRadius = null;
                            textStyle.mBorderWidth  = null;

                            // grab the text. remove any weird characters
                            string text = Regex.Replace(reader.Value, @"\t|\n|\r", "");

                            if (removedLeadingWhitespace == false)
                            {
                                removedLeadingWhitespace = true;
                                text = text.TrimStart(' ');
                            }

                            // now break it into words so we can do word wrapping
                            string[] words = text.Split(' ');
                            foreach (string word in words)
                            {
                                // create labels out of each one
                                if (string.IsNullOrEmpty(word) == false)
                                {
                                    // if the last thing we added was a special control like a reveal box, we
                                    // need the first label after that to have a leading space so it doesn't bunch up against
                                    // the control
                                    string nextWord = word;
                                    if (lastControlWasElement)
                                    {
                                        nextWord = word.Insert(0, " ");
                                        lastControlWasElement = false;
                                    }

                                    NoteText wordLabel = Parser.CreateNoteText(new CreateParams(this, availableWidth, parentParams.Height, ref textStyle), nextWord + " ");

                                    ChildControls.Add(wordLabel);
                                }
                            }

                            lastControlWasElement = false;

                            break;
                        }

                        case XmlNodeType.EndElement:
                        {
                            // if we hit the end of our label, we're done.
                            //if( reader.Name == "Paragraph" || reader.Name == "P" )
                            if (ElementTagMatches(reader.Name))
                            {
                                finishedReading = true;
                            }
                            break;
                        }
                        }
                    }

                    // should we add a URL Glyph? We're gonna be clever and add it AS a NoteText, so that it integrates with the paragraph nicely.
                    // now add our glyph, if relevant
                    TryAddUrlGlyph(availableWidth, parentParams.Height);


                    // layout all controls
                    // paragraphs are tricky.
                    // We need to lay out controls horizontally and wrap when we run out of room.

                    // To align, we need to keep track of each "row". When the row is full,
                    // we calculate its width, and then adjust each item IN that row so
                    // that the row is centered within the max width of the paragraph.
                    // The max width of the paragraph is defined as the widest row.

                    // maintain a list of all our rows so that once they are all generated,
                    // we can align them based on the widest row.
                    float maxRowWidth = 0;
                    List <List <IUIControl> > rowList = new List <List <IUIControl> >( );

                    // track where within a row we need to start a control
                    float rowRemainingWidth = availableWidth;
                    float startingX         = bounds.X + padding.Left + borderPaddingPx;

                    // always store the last placed control's height so that should
                    // our NEXT control need to wrap, we know how far down to wrap.
                    float yOffset           = bounds.Y + padding.Top + borderPaddingPx;
                    float lastControlHeight = 0;
                    float rowWidth          = 0;

                    //Create our first row and put it in our list
                    List <IUIControl> currentRow = new List <IUIControl>( );

                    rowList.Add(currentRow);

                    foreach (IUIControl control in ChildControls)
                    {
                        RectangleF controlFrame = control.GetFrame( );

                        // if there is NOT enough room on this row for the next control
                        if (rowRemainingWidth < controlFrame.Width)
                        {
                            // since we're advancing to the next row, trim leading white space, which, if we weren't wrapping,
                            // would be a space between words.
                            // note: we can safely cast to a NoteText because that's the only child type we allow.
                            string text = ((NoteText)control).GetText( ).TrimStart(' ');
                            ((NoteText)control).SetText(text);

                            // advance to the next row
                            yOffset += lastControlHeight;

                            // Reset values for the new row
                            rowRemainingWidth = availableWidth;
                            startingX         = bounds.X + padding.Left + borderPaddingPx;
                            lastControlHeight = 0;
                            rowWidth          = 0;

                            currentRow = new List <IUIControl>( );
                            rowList.Add(currentRow);
                        }

                        // Add this next control to the current row
                        currentRow.Add(control);

                        // position this control appropriately
                        control.AddOffset(startingX, yOffset);

                        // update so the next child begins beyond this one.
                        // also reduce the available width by this control's.
                        rowWidth          += controlFrame.Width;
                        startingX         += controlFrame.Width;                                                                //Increment startingX so the next control is placed after this one.
                        rowRemainingWidth -= controlFrame.Width;                                                                //Reduce the available width by what this control took.
                        lastControlHeight  = controlFrame.Height > lastControlHeight ? controlFrame.Height : lastControlHeight; //Store the height of the tallest control on this row.

                        // track the widest row
                        maxRowWidth = rowWidth > maxRowWidth ? rowWidth : maxRowWidth;
                    }

                    // give each row the legal bounds it may work with
                    RectangleF availableBounds = new RectangleF(bounds.X + padding.Left + borderPaddingPx,
                                                                bounds.Y + borderPaddingPx + padding.Top,
                                                                availableWidth,
                                                                bounds.Height);

                    // Now that we know the widest row, align all the rows
                    foreach (List <IUIControl> row in rowList)
                    {
                        AlignRow(availableBounds, row, maxRowWidth);
                    }


                    // Build our final frame that determines our dimensions
                    RectangleF frame = new RectangleF(65000, 65000, -65000, -65000);

                    // for each child control
                    foreach (IUIControl control in ChildControls)
                    {
                        // enlarge our frame by the current frame and the next child
                        frame = Parser.CalcBoundingFrame(frame, control.GetFrame( ));
                    }

                    frame.Y       = bounds.Y;
                    frame.X       = bounds.X;
                    frame.Height += padding.Height + padding.Top + (borderPaddingPx * 2); //add in padding
                    frame.Width   = bounds.Width;

                    // setup our bounding rect for the border
                    frame = new RectangleF(frame.X,
                                           frame.Y,
                                           frame.Width,
                                           frame.Height);

                    // and store that as our bounds
                    BorderView.Frame = frame;

                    Frame = frame;
                    SetDebugFrame(Frame);

                    // sort everything
                    ChildControls.Sort(BaseControl.Sort);
                }
Пример #18
0
                public ListItem(CreateParams parentParams, XmlReader reader)
                {
                    // verify that our parent is a list. That's the only acceptable place for us.
                    if ((parentParams.Parent as List) == null)
                    {
                        throw new Exception(string.Format("<ListItem> parent must be <List>. This <ListItem> parent is: <{0}>", parentParams.Parent.GetType()));
                    }

                    Initialize( );

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults(reader, ref mStyle, ref ControlStyles.mListItem);
                    mStyle.mAlignment = null; //don't use alignment

                    // check for attributes we support
                    RectangleF bounds     = new RectangleF( );
                    SizeF      parentSize = new SizeF(parentParams.Width, parentParams.Height);

                    ParseCommonAttribs(reader, ref parentSize, ref bounds);

                    //ignore positioning attributes.
                    bounds       = new RectangleF( );
                    bounds.Width = parentParams.Width;

                    // Get margins and padding
                    RectangleF padding;
                    RectangleF margin;

                    GetMarginsAndPadding(ref mStyle, ref parentSize, ref bounds, out margin, out padding);

                    // apply margins to as much of the bounds as we can (bottom must be done by our parent container)
                    ApplyImmediateMargins(ref bounds, ref margin, ref parentSize);
                    Margin = margin;


                    // check for border styling
                    int borderPaddingPx = 0;

                    if (mStyle.mBorderColor.HasValue)
                    {
                        BorderView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if (mStyle.mBorderRadius.HasValue)
                    {
                        BorderView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if (mStyle.mBorderWidth.HasValue)
                    {
                        BorderView.BorderWidth = mStyle.mBorderWidth.Value;
                        borderPaddingPx        = (int)Rock.Mobile.Graphics.Util.UnitToPx(mStyle.mBorderWidth.Value + PrivateNoteConfig.BorderPadding);
                    }

                    if (mStyle.mBackgroundColor.HasValue)
                    {
                        BorderView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }
                    //

                    // now calculate the available width based on padding. (Don't actually change our width)
                    float availableWidth = bounds.Width - padding.Left - padding.Width - (borderPaddingPx * 2);

                    // Parse Child Controls
                    bool finishedParsing = false;

                    while (finishedParsing == false && reader.Read( ))
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                        {
                            // let each child have our available width.
                            IUIControl control = Parser.TryParseControl(new CreateParams(this, availableWidth, parentParams.Height, ref mStyle), reader);
                            if (control != null)
                            {
                                ChildControls.Add(control);
                            }
                            break;
                        }

                        case XmlNodeType.Text:
                        {
                            // grab the text. remove any weird characters
                            string text = Regex.Replace(reader.Value, @"\t|\n|\r", "");

                            // now break it into words so we can do word wrapping
                            string[] words = text.Split(' ');

                            // the very very first word gets a bullet point!
                            string sentence = "";
                            foreach (string word in words)
                            {
                                // create labels out of each one
                                if (string.IsNullOrEmpty(word) == false)
                                {
                                    sentence += word + " ";
                                }
                            }

                            NoteText textLabel = Parser.CreateNoteText(new CreateParams(this, availableWidth, parentParams.Height, ref mStyle), sentence);
                            ChildControls.Add(textLabel);
                            break;
                        }

                        case XmlNodeType.EndElement:
                        {
                            // if we hit the end of our label, we're done.
                            //if( reader.Name == "ListItem" || reader.Name == "LI" )
                            if (ElementTagMatches(reader.Name))
                            {
                                finishedParsing = true;
                            }

                            break;
                        }
                        }
                    }

                    LayoutStackPanel(bounds, padding.Left, padding.Top, availableWidth, padding.Height, borderPaddingPx);
                }
Пример #19
0
 private void ClearButtonFunc_Click(object sender, RoutedEventArgs e)
 {
     NoteText.Clear();
 }
Пример #20
0
                public static IUIControl TryParseControl(Notes.BaseControl.CreateParams parentParams, XmlReader reader)
                {
                    // either create/parse a new control, or return null.
                    if (Paragraph.ElementTagMatches(reader.Name))
                    {
#if __WIN__
                        return(new EditableParagraph(parentParams, reader));
#else
                        return(new Paragraph(parentParams, reader));
#endif
                    }
                    else if (Canvas.ElementTagMatches(reader.Name))
                    {
                        return(new Canvas(parentParams, reader));
                    }
                    else if (StackPanel.ElementTagMatches(reader.Name))
                    {
                        return(new StackPanel(parentParams, reader));
                    }
                    else if (List.ElementTagMatches(reader.Name))
                    {
                        return(new List(parentParams, reader));
                    }
                    else if (ListItem.ElementTagMatches(reader.Name))
                    {
                        return(new ListItem(parentParams, reader));
                    }
                    else if (RevealBox.ElementTagMatches(reader.Name))
                    {
#if __WIN__
                        return(new EditableRevealBox(parentParams, reader));
#else
                        return(new RevealBox(parentParams, reader));
#endif
                    }
                    else if (Quote.ElementTagMatches(reader.Name))
                    {
#if __WIN__
                        return(new EditableQuote(parentParams, reader));
#else
                        return(new Quote(parentParams, reader));
#endif
                    }
                    else if (TextInput.ElementTagMatches(reader.Name))
                    {
#if __WIN__
                        return(new EditableTextInput(parentParams, reader));
#else
                        return(new TextInput(parentParams, reader));
#endif
                    }
                    else if (Header.ElementTagMatches(reader.Name))
                    {
#if __WIN__
                        return(new EditableHeader(parentParams, reader));
#else
                        return(new Header(parentParams, reader));
#endif
                    }
                    else if (NoteText.ElementTagMatches(reader.Name))
                    {
#if __WIN__
                        return(new EditableNoteText(parentParams, reader));
#else
                        return(new NoteText(parentParams, reader));
#endif
                    }

                    throw new Exception(String.Format("Control of type {0} does not exist.", reader.Name));
                }
Пример #21
0
                public List(CreateParams parentParams, XmlReader reader)
                {
                    Initialize( );

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults(reader, ref mStyle, ref ControlStyles.mList);

                    // check for attributes we support
                    RectangleF bounds     = new RectangleF( );
                    SizeF      parentSize = new SizeF(parentParams.Width, parentParams.Height);

                    ParseCommonAttribs(reader, ref parentSize, ref bounds);

                    // Get margins and padding
                    RectangleF padding;
                    RectangleF margin;

                    GetMarginsAndPadding(ref mStyle, ref parentSize, ref bounds, out margin, out padding);

                    // apply margins to as much of the bounds as we can (bottom must be done by our parent container)
                    ApplyImmediateMargins(ref bounds, ref margin, ref parentSize);
                    Margin = margin;

                    // check for border styling
                    int borderPaddingPx = 0;

                    if (mStyle.mBorderColor.HasValue)
                    {
                        BorderView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if (mStyle.mBorderRadius.HasValue)
                    {
                        BorderView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if (mStyle.mBorderWidth.HasValue)
                    {
                        BorderView.BorderWidth = mStyle.mBorderWidth.Value;
                        borderPaddingPx        = (int)Rock.Mobile.Graphics.Util.UnitToPx(mStyle.mBorderWidth.Value + PrivateNoteConfig.BorderPadding);
                    }

                    if (mStyle.mBackgroundColor.HasValue)
                    {
                        BorderView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }
                    //

                    // convert indentation if it's a percentage
                    float listIndentation = mStyle.mListIndention.Value;

                    if (listIndentation < 1)
                    {
                        listIndentation = parentParams.Width * listIndentation;
                    }

                    // now calculate the available width based on padding. (Don't actually change our width)
                    // also consider the indention amount of the list.
                    float availableWidth = bounds.Width - padding.Left - padding.Width - listIndentation - (borderPaddingPx * 2);


                    // parse for the desired list style. Default to Bullet if they didn't put anything.
                    ListType = reader.GetAttribute("Type");
                    if (string.IsNullOrEmpty(ListType) == true)
                    {
                        ListType = ListTypeBullet;
                    }

                    // Parse Child Controls
                    int numberedCount = 1;

                    // don't force our alignment, borders, bullet style or indentation on children.
                    Style style = new Style( );

                    style                = mStyle;
                    style.mAlignment     = null;
                    style.mListIndention = null;
                    style.mListBullet    = null;
                    style.mBorderColor   = null;
                    style.mBorderRadius  = null;
                    style.mBorderWidth   = null;

                    bool finishedParsing = false;

                    while (finishedParsing == false && reader.Read( ))
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                        {
                            // Create the prefix for this list item.
                            string listItemPrefixStr = mStyle.mListBullet + " ";
                            if (ListType == ListTypeNumbered)
                            {
                                listItemPrefixStr = numberedCount.ToString() + ". ";
                            }

                            NoteText textLabel = Parser.CreateNoteText(new CreateParams(this, availableWidth, parentParams.Height, ref style), listItemPrefixStr);
                            ChildControls.Add(textLabel);


                            // create our actual child, but throw an exception if it's anything but a ListItem.
                            IUIControl control = Parser.TryParseControl(new CreateParams(this, availableWidth - textLabel.GetFrame().Width, parentParams.Height, ref style), reader);

                            ListItem listItem = control as ListItem;
                            if (listItem == null)
                            {
                                throw new Exception(String.Format("Only a <ListItem> may be a child of a <List>. Found element <{0}>.", control.GetType( )));
                            }


                            // if it will actually use the bullet point, increment our count.
                            if (listItem.ShouldShowBulletPoint() == true)
                            {
                                numberedCount++;
                            }
                            else
                            {
                                // otherwise give it a blank space, and keep our count the same.
                                textLabel.SetText("  ");
                            }

                            // and finally add the actual list item.
                            ChildControls.Add(control);
                            break;
                        }

                        case XmlNodeType.EndElement:
                        {
                            // if we hit the end of our label, we're done.
                            //if( reader.Name == "List" || reader.Name == "L" )
                            if (ElementTagMatches(reader.Name))
                            {
                                finishedParsing = true;
                            }

                            break;
                        }
                        }
                    }


                    // layout all controls
                    float xAdjust = bounds.X + listIndentation;
                    float yOffset = bounds.Y + padding.Top + borderPaddingPx; //vertically they should just stack

                    // we know each child is a NoteText followed by ListItem. So, lay them out
                    // as: * - ListItem
                    //     * - ListItem
                    foreach (IUIControl control in ChildControls)
                    {
                        // position the control
                        control.AddOffset(xAdjust + padding.Left + borderPaddingPx, yOffset);

                        RectangleF controlFrame  = control.GetFrame( );
                        RectangleF controlMargin = control.GetMargin( );

                        // is this the item prefix?
                        if ((control as NoteText) != null)
                        {
                            // and update xAdjust so the actual item starts after.
                            xAdjust += controlFrame.Width;
                        }
                        else
                        {
                            // reset the values for the next line.
                            xAdjust = bounds.X + listIndentation;
                            yOffset = controlFrame.Bottom + controlMargin.Height;
                        }
                    }

                    // we need to store our bounds. We cannot
                    // calculate them on the fly because we
                    // would lose any control defined offsets, which would throw everything off.
                    bounds.Height = (yOffset - bounds.Y) + padding.Height + borderPaddingPx;
                    Frame         = bounds;

                    BorderView.Frame = bounds;

                    // store our debug frame
                    SetDebugFrame(Frame);

                    // sort everything
                    ChildControls.Sort(BaseControl.Sort);
                }