Ejemplo n.º 1
0
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoString))
     {
         ItemsControlElement itemsControlElement = this.TargetElement as ItemsControlElement;
         if (itemsControlElement != null)
         {
             ITypeId              itemType       = this.ItemType;
             StyleAsset           asset          = this.Asset;
             IProperty            targetProperty = this.SceneViewModel.ProjectContext.ResolveProperty(ItemsControlElement.ItemsProperty);
             ISceneInsertionPoint insertionPoint = (ISceneInsertionPoint) new PropertySceneInsertionPoint((SceneElement)itemsControlElement, targetProperty);
             if (asset != null && asset.CanCreateInstance(insertionPoint))
             {
                 IExpandable expandable = this.TargetElement as IExpandable;
                 if (expandable != null)
                 {
                     using (this.SceneViewModel.ForceBaseValue())
                         this.TargetElement.SetValue(expandable.ExpansionProperty, (object)true);
                 }
                 asset.CreateInstance(this.DesignerContext.LicenseManager, insertionPoint, Rect.Empty, (OnCreateInstanceAction)null);
             }
             else
             {
                 this.TypeInstantiator.CreateInstance(itemType, insertionPoint, Rect.Empty, (OnCreateInstanceAction)null);
             }
         }
         editTransaction.Commit();
     }
 }
            public void SetActiveBackPanel(IExpandable panel, Control parent)
            {
                ActiveBackPanel = panel;

                if (panel != null)
                {
                    ((Control)ActiveBackPanel).Parent = parent;
                }
            }
Ejemplo n.º 3
0
        public TreeListBoxInfo(int level, object dataItem)
        {
            this.level    = level;
            this.dataItem = dataItem;
            IExpandable expandable = dataItem as IExpandable;

            if (expandable != null)
            {
                this.isExpanded = expandable.IsExpanded;
            }
        }
Ejemplo n.º 4
0
        public bool ExpandVairableInCopy(string varName, string varExpansion, out IExpandable outCopy)
        {
            bool    didCopy = false;
            Pattern newCopy = Copy();

            if (ExpandableVars.ExpandInCopy(Value, varName, varExpansion, out object value))
            {
                didCopy       = true;
                newCopy.Value = (string)value;
            }
            outCopy = newCopy;
            return(didCopy);
        }
Ejemplo n.º 5
0
        //Adds a Shape to the SVG Document
        public virtual void AddElement(Element element)
        {
            //Get the formatter for the type of element
            if (!mFormatters.ContainsKey(element.GetType()))
            {
                throw new SvgDocumentException("A registered formatter for type " + element.GetType().ToString() + " not found.");
            }

            //Get the formatter type
            Type formatterType = (Type)mFormatters[element.GetType()];

            //Get an instance
            if (!mFormatterInstances.ContainsKey(formatterType))
            {
                object obj = Activator.CreateInstance(formatterType, null);
                mFormatterInstances.Add(formatterType, obj);
            }

            Formatter formatter = (Formatter)mFormatterInstances[formatterType];

            formatter.Reset();
            formatter.WriteElement(this, element);

            //Write out child elements if a container
            if (element is IContainer)
            {
                XmlNode    temp      = ContainerNode;
                string     tempKey   = ContainerKey;
                IContainer container = element as IContainer;

                //Add a grouping node
                ContainerKey  = element.Key;
                ContainerNode = AddGroupDefinition(element.Key + "Group", container);

                if (element is IExpandable)
                {
                    IExpandable expand = element as IExpandable;
                    if (expand.Expanded)
                    {
                        AddContainer(container);
                    }
                }
                else
                {
                    AddContainer(container);
                }

                ContainerNode = temp;
                ContainerKey  = tempKey;
            }
        }
Ejemplo n.º 6
0
        public bool StripEscapedVariablesInCopy(out IExpandable outCopy)
        {
            bool    didStrip = false;
            Pattern newCopy  = Copy();

            if (ExpandableVars.StripEscapedVariablesInCopy(Value, out object value))
            {
                didStrip      = true;
                newCopy.Value = (string)value;
            }

            outCopy = newCopy;
            return(didStrip);
        }
Ejemplo n.º 7
0
        private void RenderExpand(Table table, Graphics graphics, Render render)
        {
            //Obtain a reference to IExpandable interface
            IExpandable expand = (IExpandable)table;

            if (!expand.DrawExpand)
            {
                return;
            }

            //Draw the expander
            Pen        pen   = new Pen(Color.FromArgb(128, Color.Gray), 1);
            SolidBrush brush = new SolidBrush(Color.White);

            //Set up the expand path
            GraphicsPath expandPath = new GraphicsPath();

            expandPath.AddEllipse(table.Width - 20, 5, 14, 14);

            SmoothingMode smoothing = graphics.SmoothingMode;

            graphics.SmoothingMode = SmoothingMode.HighQuality;
            graphics.FillPath(brush, expandPath); //Fill Circle
            graphics.DrawPath(pen, expandPath);   //Outline

            pen.Color = Color.FromArgb(128, Color.Navy);
            pen.Width = 2;
            PointF[] points;

            if (expand.Expanded)
            {
                points = new PointF[] { new PointF(table.Width - 16, 11), new PointF(table.Width - 13, 8), new PointF(table.Width - 10, 11) };
            }
            else
            {
                points = new PointF[] { new PointF(table.Width - 16, 8), new PointF(table.Width - 13, 11), new PointF(table.Width - 10, 8) };
            }
            graphics.DrawLines(pen, points);
            points[0].Y += 5;
            points[1].Y += 5;
            points[2].Y += 5;
            graphics.DrawLines(pen, points);
            graphics.SmoothingMode = smoothing;
        }
Ejemplo n.º 8
0
        private int GetFlattenedTreeItemCount()
        {
            if (this.currentDataSource == null)
            {
                return(0);
            }
            int num = 0;

            foreach (object obj2 in this.currentDataSource)
            {
                num++;
                IExpandable expandable = obj2 as IExpandable;
                if ((expandable == null) || expandable.IsExpanded)
                {
                    num += this.GetFlattenedTreeDescendentCount(obj2);
                }
            }
            return(num);
        }
Ejemplo n.º 9
0
        private int GetFlattenedTreeDescendentCount(object item)
        {
            IEnumerable dataChildList = this.GetDataChildList(item);
            int         num           = 0;

            if (dataChildList != null)
            {
                foreach (object obj2 in dataChildList)
                {
                    num++;
                    IExpandable expandable = obj2 as IExpandable;
                    if ((expandable == null) || expandable.IsExpanded)
                    {
                        num += this.GetFlattenedTreeDescendentCount(obj2);
                    }
                }
            }
            return(num);
        }
Ejemplo n.º 10
0
        public virtual IList <SceneNode> CreateNodeTreeOnInsertion(SceneNode node)
        {
            List <SceneNode> list = new List <SceneNode>();

            list.Add(node);
            if (ProjectNeutralTypes.TabControl.IsAssignableFrom((ITypeId)node.Type))
            {
                ItemsControlElement itemsControlElement = (ItemsControlElement)node;
                SceneElement        sceneElement1       = (SceneElement)node.ViewModel.CreateSceneNode(ProjectNeutralTypes.TabItem);
                itemsControlElement.Items.Add((SceneNode)sceneElement1);
                list.AddRange((IEnumerable <SceneNode>) this.CreateNodeTreeOnInsertion((SceneNode)sceneElement1));
                SceneElement sceneElement2 = (SceneElement)node.ViewModel.CreateSceneNode(ProjectNeutralTypes.TabItem);
                itemsControlElement.Items.Add((SceneNode)sceneElement2);
                list.AddRange((IEnumerable <SceneNode>) this.CreateNodeTreeOnInsertion((SceneNode)sceneElement2));
            }
            else if (PlatformTypes.Popup.IsAssignableFrom((ITypeId)node.Type) || ProjectNeutralTypes.Expander.IsAssignableFrom((ITypeId)node.Type) || ProjectNeutralTypes.TabItem.IsAssignableFrom((ITypeId)node.Type))
            {
                GridElement         gridElement         = (GridElement)node.ViewModel.CreateSceneNode(PlatformTypes.Grid);
                SolidColorBrushNode solidColorBrushNode = (SolidColorBrushNode)node.ViewModel.CreateSceneNode(PlatformTypes.SolidColorBrush);
                solidColorBrushNode.SetValueAsWpf(SolidColorBrushNode.ColorProperty, (object)Color.FromArgb(byte.MaxValue, (byte)229, (byte)229, (byte)229));
                gridElement.SetValueAsSceneNode(PanelElement.BackgroundProperty, (SceneNode)solidColorBrushNode);
                SceneElement sceneElement = (SceneElement)node;
                if (sceneElement.DefaultInsertionPoint != null)
                {
                    sceneElement.DefaultInsertionPoint.Insert((SceneNode)gridElement);
                    list.Add((SceneNode)gridElement);
                    IExpandable expandable = node as IExpandable;
                    if (expandable != null)
                    {
                        expandable.EnsureExpandable();
                        if (sceneElement.ProjectContext.ResolveProperty(expandable.DesignTimeExpansionProperty) != null)
                        {
                            node.SetLocalValue(expandable.DesignTimeExpansionProperty, (object)true);
                        }
                    }
                }
            }
            return((IList <SceneNode>)list);
        }
Ejemplo n.º 11
0
        public virtual SceneNode CreateInstance(ITypeId instanceType, ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action)
        {
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.PropertyInspectorFromCreate);
            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.CreateElement);
            SceneView sceneView = this.sceneView;

            if (sceneView == null || !sceneView.IsEditable || insertionPoint == null)
            {
                return((SceneNode)null);
            }
            SceneNode rawInstance = this.CreateRawInstance(instanceType);

            if (rawInstance == null || !insertionPoint.CanInsert((ITypeId)rawInstance.Type))
            {
                return((SceneNode)null);
            }
            if (rect.IsEmpty)
            {
                rect = new Rect(0.0, 0.0, double.NaN, double.NaN);
            }
            if (double.IsInfinity(rect.Width))
            {
                rect.Width = double.NaN;
            }
            if (double.IsInfinity(rect.Height))
            {
                rect.Height = double.NaN;
            }
            using (this.ViewModel.ForceBaseValue())
            {
                using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitCreateControlFormat, new object[1]
                {
                    (object)instanceType.Name
                })))
                {
                    IExpandable expandable = insertionPoint.SceneElement as IExpandable;
                    if (expandable != null)
                    {
                        insertionPoint.SceneNode.SetValue(expandable.ExpansionProperty, (object)true);
                    }
                    bool flag = this.ShouldUseDefaultInitializer && Enumerable.Any <FeatureProvider>(DefaultTypeInstantiator.GetDefaultInitializers(rawInstance));
                    IList <SceneNode> nodes = (IList <SceneNode>)null;
                    if (!flag)
                    {
                        nodes = this.CreateNodeTreeOnInsertion(rawInstance);
                        this.ApplyBeforeInsertionDefaultsToElements(nodes, rawInstance, new DefaultTypeInstantiator.SceneElementNamingCallback(DefaultTypeInstantiator.TypeNameCallback));
                    }
                    SceneNode    layoutTarget    = DefaultTypeInstantiator.GetLayoutTarget(rawInstance);
                    SceneElement selectionTarget = DefaultTypeInstantiator.GetSelectionTarget(rawInstance);
                    this.ViewModel.ElementSelectionSet.Clear();
                    insertionPoint.Insert(rawInstance);
                    editTransaction.Update();
                    this.ApplyDefaultInitializers(rawInstance);
                    if (action != null)
                    {
                        action(rawInstance);
                        editTransaction.Update();
                    }
                    if (!flag)
                    {
                        this.ApplyAfterInsertionDefaultsToElements(nodes, rawInstance);
                    }
                    SceneElement sceneElement1 = layoutTarget as SceneElement;
                    EffectNode   effectNode    = layoutTarget as EffectNode;
                    if (sceneElement1 != null && sceneElement1.IsViewObjectValid)
                    {
                        if (selectionTarget != null)
                        {
                            this.ViewModel.ElementSelectionSet.SetSelection(selectionTarget);
                        }
                        this.SetLayout(insertionPoint, rect, rawInstance, layoutTarget, editTransaction);
                    }
                    else if (effectNode != null)
                    {
                        this.ViewModel.ChildPropertySelectionSet.SetSelection((SceneNode)effectNode);
                    }
                    else
                    {
                        for (SceneNode sceneNode = layoutTarget; sceneNode != null; sceneNode = sceneNode.Parent)
                        {
                            SceneElement sceneElement2 = sceneNode as SceneElement;
                            if (sceneElement2 != null && sceneElement2.Visual != null && sceneElement2.Visual is IViewVisual)
                            {
                                this.sceneView.EnsureVisible(sceneElement2.Visual);
                                break;
                            }
                        }
                    }
                    if (this.ViewModel.DesignerContext.AmbientPropertyManager != null)
                    {
                        this.ViewModel.DesignerContext.AmbientPropertyManager.ApplyAmbientProperties(rawInstance);
                    }
                    editTransaction.Commit();
                }
            }
            return(rawInstance);
        }
 protected virtual void ClosePanel(IExpandable panel)
 {
     panel.Shrink();
     EnableKeypad();
 }