示例#1
0
            /**
             * Override of the WidgetBase AddChild function
             */
            public override void AddChild(IWidget child)
            {
                base.AddChild(child);
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    System.Windows.Controls.ListBoxItem item = new System.Windows.Controls.ListBoxItem();
                    WidgetBaseWindowsPhone widget            = (child as WidgetBaseWindowsPhone);
                    item.Content = widget.View;
                    if (widget.fillSpaceHorizontalyEnabled)
                    {
                        item.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                    }
                    else
                    {
                        item.HorizontalContentAlignment = HorizontalAlignment.Left;
                    }

                    if (widget.fillSpaceVerticalyEnabled)
                    {
                        item.VerticalContentAlignment = VerticalAlignment.Stretch;
                    }
                    else
                    {
                        item.VerticalContentAlignment = VerticalAlignment.Center;
                    }
                    mList.Items.Add(item);
                });
            }
示例#2
0
            /**
             * Adds a ListViewItem to the main list.
             * @param child The list view item to be added.
             */
            private void AddListItem(IWidget child)
            {
                base.AddChild(child);
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    System.Windows.Controls.ListBoxItem item = new System.Windows.Controls.ListBoxItem();
                    WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);
                    item.Content = widget.View;
                    if (widget.FILL_SPACE_H)
                    {
                        item.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                    }
                    else
                    {
                        item.HorizontalContentAlignment = HorizontalAlignment.Left;
                    }

                    if (widget.FILL_SPACE_V)
                    {
                        item.VerticalContentAlignment = VerticalAlignment.Stretch;
                    }
                    else
                    {
                        item.VerticalContentAlignment = VerticalAlignment.Center;
                    }
                    mList.Items.Add(item);
                });
            }
示例#3
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("currentHour") || propertyName.Equals("currentMinute"))
                {
                    int val;
                    if (!int.TryParse(propertyValue, out val))
                    {
                        isPropertyValid = false;
                    }

                    if (propertyName.Equals("currentHour"))
                    {
                        if (val >= 24 || val < 0)
                        {
                            isPropertyValid = false;
                        }
                    }
                    else if (propertyName.Equals("currentMinute"))
                    {
                        if (val >= 60 || val < 0)
                        {
                            isPropertyValid = false;
                        }
                    }
                }

                return(isPropertyValid);
            }
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("childHorizontalAlignment"))
                {
                    if (!(propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_LEFT) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_RIGHT) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_CENTER)))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("childVerticalAlignment"))
                {
                    if (!(propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_BOTTOM) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_TOP) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_CENTER)))
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#5
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("icon"))
                {
                    int val = 0;
                    if (!int.TryParse(propertyValue, out val))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("fontColor"))
                {
                    try
                    {
                        System.Windows.Media.SolidColorBrush brush;
                        MoSync.Util.ConvertStringToColor(propertyValue, out brush);
                    }
                    catch (InvalidPropertyValueException)
                    {
                        isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#6
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("maxdateyear") || propertyName.Equals("maxdatemonth") || propertyName.Equals("maxdateday") ||
                    propertyName.Equals("mindateyear") || propertyName.Equals("mindatemonth") || propertyName.Equals("mindateday"))
                {
                    int value;
                    if (!int.TryParse(propertyValue, out value))
                    {
                        isPropertyValid = false;
                    }
                    if (propertyName.Equals("maxdateyear"))
                    {
                        if (MinDate > MaxDate.AddYears(-1 * (MaxDate.Year - value)) || value > MaxYear) isPropertyValid = false;
                    }
                    else if (propertyName.Equals("maxdatemonth"))
                    {
                        if (value <= 12 && value >= 1)
                        {
                            if (MinDate > MaxDate.AddMonths(-1 * (MaxDate.Month - value))) isPropertyValid = false;
                        }
                        else
                        {
                            isPropertyValid = false;
                        }
                    }
                    else if (propertyName.Equals("maxdateday"))
                    {
                        int month = MaxDate.Month;
                        if (MinDate > MaxDate.AddDays(value - MaxDate.Day)) isPropertyValid = false;
                        // If the month have changed it means that the day value was not valid.
                        if (month != MaxDate.AddDays(value - MaxDate.Day).Month) isPropertyValid = false;
                    }
                    else if (propertyName.Equals("mindateyear"))
                    {
                        if (MinDate.AddYears(-1 * (MinDate.Year - value)) > MaxDate || value < MinYear) isPropertyValid = false;
                    }
                    else if (propertyName.Equals("mindatemonth"))
                    {
                        if (value <= 12 && value >= 1)
                        {
                            if (MinDate.AddMonths(-1 * (MinDate.Month - value)) > MaxDate) isPropertyValid = false;
                        }
                        else
                        {
                            isPropertyValid = false;
                        }
                    }
                    else if (propertyName.Equals("mindateday"))
                    {
                        int month = MinDate.Month;
                        if (MinDate.AddDays(value - MinDate.Day) > MaxDate) isPropertyValid = false;
                        // IF the month have changed it means that the day value was not valid.
                        if (month != MinDate.AddDays(value - MinDate.Day).Month) isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#7
0
            /**
            * The RemoveChild implementation
            * @param child IWidget the "child" widget that will be removed
            */
            public override void RemoveChild(IWidget child)
            {
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);
                    FrameworkElement fw = (widget.View) as System.Windows.FrameworkElement;

                    if (mGrid.Children.Contains(mStackPanels[widget.RowNumber - 1]))
                    {
                        if (RemoveWidgetFromStackPanelContainer(child, widget.RowNumber))
                        {
                            mGrid.Children.Remove(fw);
                            mGrid.Children.Remove(mStackPanels[widget.RowNumber - 1]);
                        }
                    }
                    if (mGrid.Children.Contains(fw))
                    {
                        int x = widget.RowNumber;

                        if (x < mGrid.RowDefinitions.Count)
                        {
                            mGrid.RowDefinitions.RemoveAt(x);
                            mGrid.Children.Remove(fw);
                        }
                    }
                });
                base.RemoveChild(child);
            }
示例#8
0
 public override void AddChild(IWidget child)
 {
     base.AddChild(child);
     MoSync.Util.RunActionOnMainThreadSync(() =>
         {
             WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);
             mGrid.Children.Add(widget.View);
         });
 }
示例#9
0
 /**
  * The RemoveChild implementation
  * @param child IWidget the "child" widget that will be removed
  */
 public override void RemoveChild(IWidget child)
 {
     MoSync.Util.RunActionOnMainThreadSync(() =>
     {
         WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);
         mPanel.Children.Remove((child as WidgetBaseWindowsPhone).View);
     });
     base.RemoveChild(child);
 }
示例#10
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isBasePropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);
                if (isBasePropertyValid == false)
                {
                    return false;
                }

                return true;
            }
示例#11
0
 /**
  * Inserts a list view item at a certain index.
  * @param child The widget to be added to the list.
  * @param index The index where the widget should be added.
  */
 private void InsertListItem(IWidget child, int index)
 {
     base.InsertChild(child, index);
     MoSync.Util.RunActionOnMainThreadSync(() =>
     {
         System.Windows.Controls.ListBoxItem item = new System.Windows.Controls.ListBoxItem();
         WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);
         item.Content = widget.View;
         mList.Items.Insert(index, item);
     });
 }
示例#12
0
            // The AddChild implementation
            public override void AddChild(IWidget child)
            {
                base.AddChild(child);

                WidgetBaseWindowsPhone w = (WidgetBaseWindowsPhone)child;

                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    mDialogView.Children.Add(w.View);
                });
            }
示例#13
0
            /**
             * AddChild implementation
             * @param child IWidget the "child" widget that needs to be added
             */
            public override void AddChild(IWidget child)
            {
                base.AddChild(child);
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);

                    mPanel.Children.Add(widget.View);
                    mContentHeight += widget.Height;
                    mContentWidth  += widget.Width;
                });
            }
示例#14
0
            /*
             * The AddChild implementation.
             * @param child IWidget the "child" widget that will be added.
             *
             * Note:
             * Since the screen can have only one visible child, probably a layout,
             * each widget added as a direct child to the screen will fill the screen.
             */
            public override void AddChild(IWidget child)
            {
                base.AddChild(child);

                WidgetBaseWindowsPhone w = (WidgetBaseWindowsPhone)child;

                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    mPage.Children.Add(w.View);
                    Grid.SetColumn((w.View as FrameworkElement), 0);
                    Grid.SetRow((w.View as FrameworkElement), 0);
                });
            }
示例#15
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("navigate"))
                {
                    if (!(propertyValue.Equals("back") ||
                          propertyValue.Equals("forward")))
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#16
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("checked"))
                {
                    bool checkedVal;
                    if (!bool.TryParse(propertyValue, out checkedVal))
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#17
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("scrollable"))
                {
                    bool val;
                    if (!Boolean.TryParse(propertyValue, out val))
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#18
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("inProgress"))
                {
                    bool myValue;
                    if (!bool.TryParse(propertyValue, out myValue))
                    {
                        isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#19
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("type"))
                {
                    int type = -1;
                    if (int.TryParse(propertyValue, out type))
                    {
                        if (!(type == MoSync.Constants.MAW_LIST_VIEW_TYPE_ALPHABETICAL ||
                            type == MoSync.Constants.MAW_LIST_VIEW_TYPE_DEFAULT ||
                            type == MoSync.Constants.MAW_LIST_VIEW_TYPE_SEGMENTED))
                        {
                            isPropertyValid = false;
                        }
                    }
                    else
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("style"))
                {
                    int style = -1;
                    if (int.TryParse(propertyValue, out style))
                    {
                        if (!(style == MoSync.Constants.MAW_LIST_VIEW_STYLE_SUBTITLE ||
                            style == MoSync.Constants.MAW_LIST_VIEW_STYLE_NO_SUBTITLE))
                        {
                            isPropertyValid = false;
                        }
                    }
                    else
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("allowselection"))
                {
                    bool allowSelection = false;
                    if (!Boolean.TryParse(propertyValue, out allowSelection))
                    {
                        isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#20
0
 /**
  * The RemoveChild implementation
  * @param child IWidget the "child" widget that will be removed
  */
 public override void RemoveChild(IWidget child)
 {
     MoSync.Util.RunActionOnMainThreadSync(() =>
     {
         WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);
         int x = Grid.GetColumn((widget.View) as System.Windows.FrameworkElement);
         if ((x + 1) < mGrid.ColumnDefinitions.Count)
         {
             mGrid.ColumnDefinitions.RemoveAt(x + 1);
             mGrid.ColumnDefinitions.RemoveAt(x);
             mGrid.ColumnDefinitions.RemoveAt(x - 1);
             mGrid.Children.Remove((child as WidgetBaseWindowsPhone).View);
         }
     });
     base.RemoveChild(child);
 }
示例#21
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("latitude") ||
                    propertyName.Equals("longitude"))
                {
                    double val;
                    if (!Double.TryParse(propertyValue, out val))
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#22
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("textVerticalAlignment"))
                {
                    if (!(propertyValue.Equals("MoSync.Constants.MAW_ALIGNMENT_TOP") ||
                          propertyValue.Equals("MoSync.Constants.MAW_ALIGNMENT_CENTER") ||
                          propertyValue.Equals("MoSync.Constants.MAW_ALIGNMENT_BOTTOM")))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("textHorizontalAlignment"))
                {
                    if (!(propertyValue.Equals("MoSync.Constants.MAW_ALIGNMENT_LEFT") ||
                          propertyValue.Equals("MoSync.Constants.MAW_ALIGNMENT_RIGHT") ||
                          propertyValue.Equals("MoSync.Constants.MAW_ALIGNMENT_CENTER")))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("fontSize"))
                {
                    double          size     = 0;
                    NumberStyles    style    = NumberStyles.AllowDecimalPoint;
                    IFormatProvider provider = CultureInfo.InvariantCulture;
                    if (!Double.TryParse(propertyValue, style, provider, out size))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("fontColor"))
                {
                    try
                    {
                        System.Windows.Media.SolidColorBrush brush;
                        MoSync.Util.ConvertStringToColor(propertyValue, out brush);
                    }
                    catch (InvalidPropertyValueException)
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#23
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("type"))
                {
                    if (!(propertyValue.Equals(MoSync.Constants.MAW_MAP_TYPE_ROAD) ||
                          propertyValue.Equals(MoSync.Constants.MAW_MAP_TYPE_SATELLITE)))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("center_latitude") ||
                         propertyName.Equals("center_longitude") ||
                         propertyName.Equals("visible_area_upper_left_corner_latitude") ||
                         propertyName.Equals("visible_area_upper_left_corner_longitude") ||
                         propertyName.Equals("visible_area_lower_right_corner_latitude") ||
                         propertyName.Equals("visible_area_lower_right_corner_longitude"))
                {
                    double latitude;
                    if (!Double.TryParse(propertyValue, out latitude))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("center_zoom_level"))
                {
                    int zoomLevel;
                    if (!Int32.TryParse(propertyValue, out zoomLevel))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("interraction_enabled") ||
                         propertyName.Equals("centered") ||
                         propertyName.Equals("centered_on_visible_area"))
                {
                    bool val;
                    if (!Boolean.TryParse(propertyValue, out val))
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#24
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("max"))
                {
                    int val;
                    if (!int.TryParse(propertyValue, out val))
                    {
                        isPropertyValid = false;
                    }
                    if (val < 0)
                    {
                        isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#25
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("childVerticalAlignment") || propertyName.Equals("childHorizontalAlignment"))
                {
                    int val;
                    if (!int.TryParse(propertyValue, out val))
                    {
                        isPropertyValid = false;
                    }

                    if (propertyName.Equals("childVerticalAlignment"))
                    {
                        if (!(propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_BOTTOM) ||
                            propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_TOP) ||
                            propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_CENTER)))
                        {
                            isPropertyValid = false;
                        }
                    }
                    else if (propertyName.Equals("childHorizontalAlignment"))
                    {
                        if (!(propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_LEFT) ||
                            propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_RIGHT) ||
                            propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_CENTER)))
                        {
                            isPropertyValid = false;
                        }
                    }
                }
                else if (propertyName.Equals("scrollable"))
                {
                    bool val;
	                if (!Boolean.TryParse(propertyValue, out val))
	                {
                        isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#26
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("latitude") ||
                    propertyName.Equals("longitude"))
                {
                    IFormatProvider provider = CultureInfo.InvariantCulture;
                    try
                    {
                        double val = double.Parse(propertyValue, provider);
                    }
                    catch
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#27
0
            /**
             * Shifts all the widget/stackpanel columns inside the current grid (starting from column gridIndex).
             * Used when inserting widgets into the main grid.
             * @param gridIndex The index of the first grid column that needs to be shifted.
             */
            private void ShiftWidgetColumns(int gridIndex)
            {
                int rowIndex = 1;
                // the column at position mGrid.ColumnDefinitions.Count - 1 is a spacer column
                // the column at position mGrid.ColumnDefinitions.Count - 2 is a free column that will get filled
                // so we start at mGrid.ColumnDefinitions.Count - 3 - this is the first column where we need to shift
                // its content
                int columnds = mGrid.ColumnDefinitions.Count;

                for (int i = mGrid.ColumnDefinitions.Count - 3; i >= gridIndex; i--)
                {
                    // first get every control that is included in the current column
                    var controls = from d in mGrid.Children
                                   where Grid.GetColumn(d as FrameworkElement) == i &&
                                   Grid.GetRow(d as FrameworkElement) == rowIndex
                                   select d;

                    // shift all the controls with one position
                    while (controls.Count() > 0)
                    {
                        int controlcount         = controls.Count();
                        FrameworkElement control = controls.First() as FrameworkElement;
                        int controlColumn        = Grid.GetColumn(control);
                        int newGridColumn        = controlColumn + 1 < mGrid.ColumnDefinitions.Count - 1
                            ? controlColumn + 1 : mGrid.ColumnDefinitions.Count - 2;
                        Grid.SetColumn(control, newGridColumn);
                    }

                    // go through all the widget and modify their column numbers
                    for (int j = 0; j < mChildren.Count; j++)
                    {
                        WidgetBaseWindowsPhone widget = mChildren[j] as WidgetBaseWindowsPhone;
                        if (widget.ColumnNumber == i)
                        {
                            int newGridColumn = i + 1 < mGrid.ColumnDefinitions.Count - 1
                                ? i + 1 : mGrid.ColumnDefinitions.Count - 2;
                            widget.ColumnNumber = newGridColumn;
                        }
                    }
                }
            }
示例#28
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("scaleMode"))
                {
                    if (!(propertyValue.Equals("none") ||
                        propertyValue.Equals("scaleXY") ||
                        propertyValue.Equals("scalePreserveAspect")))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("imagePath"))
                {
                    //Take the store for the application (an image of the sandbox)
                    IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreForApplication();

                    //Verify that the file exists on the isolated storage
                    if (f.FileExists(propertyValue))
                    {
                        try
                        {
                            //Create a file stream for the required file
                            IsolatedStorageFileStream fs = new IsolatedStorageFileStream(propertyValue, System.IO.FileMode.Open, f);
                        }
                        catch
                        {
                            // There was a problem reading the image file.
                            isPropertyValid = false;
                        }
                    }
                    else
                    {
                        isPropertyValid = false;
                    }
                }

                return isPropertyValid;
            }
示例#29
0
            /**
             * Validates a property based on the property name and property value.
             * @param propertyName The name of the property to be checked.
             * @param propertyValue The value of the property to be checked.
             * @returns true if the property is valid, false otherwise.
             */
            public new static bool ValidateProperty(string propertyName, string propertyValue)
            {
                bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue);

                if (propertyName.Equals("textVerticalAlignment"))
                {
                    if (!(propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_TOP) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_BOTTOM) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_CENTER)))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("textHorizontalAlignment"))
                {
                    if (!(propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_LEFT) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_RIGHT) ||
                          propertyValue.Equals(MoSync.Constants.MAW_ALIGNMENT_CENTER)))
                    {
                        isPropertyValid = false;
                    }
                }
                else if (propertyName.Equals("fontColor"))
                {
                    try
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            System.Windows.Media.SolidColorBrush brush;
                            MoSync.Util.ConvertStringToColor(propertyValue, out brush);
                        });
                    }
                    catch (InvalidPropertyValueException)
                    {
                        isPropertyValid = false;
                    }
                }

                return(isPropertyValid);
            }
示例#30
0
            /**
             * Shifts all the widget/stackpanel rows inside the current grid (starting from row gridIndex).
             * Used when inserting widgets into the main grid.
             * @param gridIndex The index of the first grid row that needs to be shifted.
             */
            private void ShiftWidgetRows(int gridIndex)
            {
                int columnIndex = 1;
                // the row at position mGrid.RowDefinitions.Count - 1 is a spacer row
                // the row at position mGrid.RowDefinitions.Count - 2 is a free row that will get filled
                // so we start at mGrid.RowDefinitions.Count - 3 - this is the first row where we need to shift
                // its content
                for (int i = mGrid.RowDefinitions.Count - 3; i >= gridIndex ; i--)
                {
                    // first get every control that is included in the current row
                    var controls = from d in mGrid.Children
                                   where Grid.GetColumn(d as FrameworkElement) == columnIndex
                                      && Grid.GetRow(d as FrameworkElement) == i
                                   select d;

                    // shift all the controls with one position
                    while (controls.Count() > 0)
                    {
                        int controlcount = controls.Count();
                        FrameworkElement control = controls.First() as FrameworkElement;
                        int controlRow = Grid.GetRow(control);
                        int newGridRow = controlRow + 1 < mGrid.RowDefinitions.Count - 1 ? controlRow + 1 : mGrid.RowDefinitions.Count - 2;
                        Grid.SetRow(control, newGridRow);
                    }

                    // go through all the widget and modify their row numbers
                    // TODO SA: should this loop start from gridIndex?
                    for (int j = 0; j < mChildren.Count; j++)
                    {
                        WidgetBaseWindowsPhone widget = mChildren[j] as WidgetBaseWindowsPhone;
                        if (widget.RowNumber == i)
                        {
                            int newGridRow = i + 1 < mGrid.RowDefinitions.Count - 1 ? i + 1 : mGrid.RowDefinitions.Count - 2;
                            widget.RowNumber = newGridRow;
                        }
                    }
                }
            }