Esempio n. 1
0
        private void CmbLayouts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (CurrentLayout != null)
            {
                CurrentLayout.Renamed -= CurrentLayout_Renamed;
            }

            if (CmbLayouts.SelectedItem != null)
            {
                BlsFrom.CurrentDefiniton = BlsTo.CurrentDefiniton = ProjectController.BlockManager.GetDefiniton(CmbDefinitions.SelectedIndex);
                CurrentLayout            = BlsTo.BlockLayout = (BlockLayout)CmbLayouts.SelectedItem;
                BtnDelete.Enabled        = BtnRename.Enabled = true;
            }
            else
            {
                CurrentLayout     = null;
                BlsTo.BlockLayout = null;
                BtnDelete.Enabled = BtnRename.Enabled = false;
            }

            if (CurrentLayout != null)
            {
                CurrentLayout.Renamed += new EventHandler <TEventArgs <string> >(CurrentLayout_Renamed);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the actual item template size, using a non-databound materialized
        /// view of the template.
        /// </summary>
        /// <param name="dataTemplate">A data template</param>
        /// <returns>The actual size of the template</returns>
        private CGSize GetTemplateSize(DataTemplate dataTemplate, NSString elementKind)
        {
            //TODO: this should take an available breadth
            CGSize size;

            // Cache the sizes to avoid creating new templates everytime.
            if (!_templateCache.TryGetValue(dataTemplate ?? _nullDataTemplateKey, out size))
            {
                var container = CreateContainerForElementKind(elementKind);

                // Force a null DataContext so the parent's value does not flow
                // through when temporarily adding the container to Owner.XamlParent
                container.SetValue(FrameworkElement.DataContextProperty, null);

                Style style = null;
                if (elementKind == NativeListViewBase.ListViewItemElementKind)
                {
                    style = Owner.ItemContainerStyle;
                }
                else if (elementKind == NativeListViewBase.ListViewSectionHeaderElementKind)
                {
                    style = Owner.GroupStyle?.HeaderContainerStyle;
                }
                if (style != null)
                {
                    container.Style = style;
                }

                container.ContentTemplate = dataTemplate;
                try
                {
                    // Attach templated container to visual tree while measuring. This works around the bug that default Style is not
                    // applied until view is loaded.
                    Owner.XamlParent.AddSubview(BlockLayout);
                    BlockLayout.AddSubview(container);
                    // Measure with PositiveInfinity rather than MaxValue, since some views handle this better.
                    size = Owner.NativeLayout.Layouter.MeasureChild(container, new Size(double.PositiveInfinity, double.PositiveInfinity));

                    if ((size.Height > nfloat.MaxValue / 2 || size.Width > nfloat.MaxValue / 2) &&
                        this.Log().IsEnabled(LogLevel.Warning)
                        )
                    {
                        this.Log().LogWarning($"Infinite item size reported, this can crash {nameof(UICollectionView)}.");
                    }
                }
                finally
                {
                    Owner.XamlParent.RemoveChild(BlockLayout);
                    BlockLayout.RemoveChild(container);

                    // Reset the DataContext for reuse.
                    container.ClearValue(FrameworkElement.DataContextProperty);
                }

                _templateCache[dataTemplate ?? _nullDataTemplateKey] = size;
            }

            return(size);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the actual item template size, using a non-databound materialized
        /// view of the template.
        /// </summary>
        /// <param name="dataTemplate">A data template</param>
        /// <returns>The actual size of the template</returns>
        private CGSize GetTemplateSize(DataTemplate dataTemplate, NSString elementKind)
        {
            //TODO: this should take an available breadth
            CGSize size;

            // Cache the sizes to avoid creating new templates everytime.
            if (!_templateCache.TryGetValue(dataTemplate ?? _nullDataTemplateKey, out size))
            {
                var container = CreateContainerForElementKind(elementKind);

                Style style = null;
                if (elementKind == NativeListViewBase.ListViewItemElementKind)
                {
                    style = Owner.ItemContainerStyle;
                }
                else if (elementKind == NativeListViewBase.ListViewSectionHeaderElementKind)
                {
                    style = Owner.GroupStyle?.HeaderContainerStyle;
                }
                if (style != null)
                {
                    container.Style = style;
                }

                container.ContentTemplate = dataTemplate;
                try
                {
                    // Attach templated container to visual tree while measuring. This works around the bug that default Style is not
                    // applied until view is loaded.
                    Owner.XamlParent.AddSubview(BlockLayout);
                    BlockLayout.AddSubview(container);
                    size = Owner.NativeLayout.Layouter.MeasureChild(container, new Size(double.MaxValue, double.MaxValue));

                    if ((size.Height > nfloat.MaxValue / 2 || size.Width > nfloat.MaxValue / 2) &&
                        this.Log().IsEnabled(LogLevel.Warning)
                        )
                    {
                        this.Log().LogWarning($"Infinite item size reported, this can crash {nameof(UICollectionView)}.");
                    }
                }
                finally
                {
                    Owner.XamlParent.RemoveChild(BlockLayout);
                    BlockLayout.RemoveChild(container);
                }

                _templateCache[dataTemplate ?? _nullDataTemplateKey] = size;
            }

            return(size);
        }
Esempio n. 4
0
 public void ShowDialog(int definitionIndex, int graphics1, int graphics2, int paletteIndex, BlockLayout layout)
 {
     CmbGraphics1.SelectedIndex   = graphics1;
     CmbGraphics2.SelectedIndex   = graphics2;
     CmbPalettes.SelectedIndex    = paletteIndex;
     CmbLayouts.SelectedItem      = layout;
     CmbDefinitions.SelectedIndex = definitionIndex;
     CmbDefinitions_SelectedIndexChanged(null, null);
     this.ShowDialog();
 }
Esempio n. 5
0
        void ReleaseDesignerOutlets()
        {
            if (DaysButton != null)
            {
                DaysButton.Dispose();
                DaysButton = null;
            }

            if (DescriptionLabel != null)
            {
                DescriptionLabel.Dispose();
                DescriptionLabel = null;
            }

            if (DescriptionLayout != null)
            {
                DescriptionLayout.Dispose();
                DescriptionLayout = null;
            }

            if (DescriptionText != null)
            {
                DescriptionText.Dispose();
                DescriptionText = null;
            }

            if (DueDateImage != null)
            {
                DueDateImage.Dispose();
                DueDateImage = null;
            }

            if (DueDateLabel != null)
            {
                DueDateLabel.Dispose();
                DueDateLabel = null;
            }

            if (DueDateLayout != null)
            {
                DueDateLayout.Dispose();
                DueDateLayout = null;
            }

            if (SideBar != null)
            {
                SideBar.Dispose();
                SideBar = null;
            }

            if (TagsImage != null)
            {
                TagsImage.Dispose();
                TagsImage = null;
            }

            if (TagsLayout != null)
            {
                TagsLayout.Dispose();
                TagsLayout = null;
            }

            if (TagsText != null)
            {
                TagsText.Dispose();
                TagsText = null;
            }

            if (TitleImage != null)
            {
                TitleImage.Dispose();
                TitleImage = null;
            }

            if (TitleLayout != null)
            {
                TitleLayout.Dispose();
                TitleLayout = null;
            }

            if (TitleText != null)
            {
                TitleText.Dispose();
                TitleText = null;
            }

            if (WillDoLabel != null)
            {
                WillDoLabel.Dispose();
                WillDoLabel = null;
            }

            if (CreatedLabel != null)
            {
                CreatedLabel.Dispose();
                CreatedLabel = null;
            }

            if (CreatedDateLabel != null)
            {
                CreatedDateLabel.Dispose();
                CreatedDateLabel = null;
            }

            if (CompletedLabel != null)
            {
                CompletedLabel.Dispose();
                CompletedLabel = null;
            }

            if (CompletedDateLabel != null)
            {
                CompletedDateLabel.Dispose();
                CompletedDateLabel = null;
            }

            if (DetailsLayout != null)
            {
                DetailsLayout.Dispose();
                DetailsLayout = null;
            }

            if (BlockLayout != null)
            {
                BlockLayout.Dispose();
                BlockLayout = null;
            }
        }