Esempio n. 1
0
        public Boolean LoadWorkflow(String markupFileName)
        {
            ClearWorkflow();

            _designSurface = new DesignSurface();
            _wfLoader.MarkupFileName = markupFileName;
            _wfLoader.NewWorkflowType = null;

            return CommonWorkflowLoading();
        }
Esempio n. 2
0
        public Boolean CreateNewWorkflow(Type workflowType, String newWorkflowName)
        {
            ClearWorkflow();

            _designSurface = new DesignSurface();
            _wfLoader.MarkupFileName = String.Empty;
            _wfLoader.NewWorkflowType = workflowType;
            _wfLoader.NewWorkflowName = newWorkflowName;

            return CommonWorkflowLoading();
        }
        public void LoadWorkflow(string xoml, string ruleSetXml)
        {
            SuspendLayout();

            DesignSurface  designSurface = new DesignSurface();
            WorkflowLoader loader        = new WorkflowLoader();

            loader.RuleSetXml = ruleSetXml;
            loader.Xoml       = xoml;
            designSurface.BeginLoad(loader);

            IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (designerHost != null && designerHost.RootComponent != null)
            {
                IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
                if (rootDesigner != null)
                {
                    UnloadWorkflow();

                    this.designSurface = designSurface;
                    this.loader        = loader;
                    this.workflowView  = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                    this.workflowViewSplitter.Panel2.Controls.Add(this.workflowView);
                    this.workflowView.Dock               = DockStyle.Fill;
                    this.workflowView.TabIndex           = 1;
                    this.workflowView.TabStop            = true;
                    this.workflowView.HScrollBar.TabStop = false;
                    this.workflowView.VScrollBar.TabStop = false;
                    this.workflowView.Focus();
                    this.propertyGrid.Site = designerHost.RootComponent.Site;

                    ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                    if (selectionService != null)
                    {
                        selectionService.SelectionChanged += new EventHandler(OnSelectionChanged);
                    }
                }
            }

            ResumeLayout(true);

            //Add the code compile unit for the xaml file
            TypeProvider typeProvider = (TypeProvider)GetService(typeof(ITypeProvider));

            this.loader.XamlCodeCompileUnit = new CodeCompileUnit();
            this.loader.XamlCodeCompileUnit.Namespaces.Add(Helpers.GenerateCodeFromXomlDocument(Helpers.GetRootActivity(xoml), this, ref this.nameSpace, ref this.typeName));
            typeProvider.AddCodeCompileUnit(this.loader.XamlCodeCompileUnit);

            this.loader.CodeBesideCCU = new CodeCompileUnit();
            this.loader.CodeBesideCCU.Namespaces.Add(Helpers.GenerateCodeBeside(Helpers.GetRootActivity(xoml), this));
            typeProvider.AddCodeCompileUnit(this.loader.CodeBesideCCU);
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the boolean operation being changed.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void BooleanChanged(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Save new value
            SelectedGroup.IsBooleanConstruct = (BooleanCheckbox.IntValue == 1);

            // Update UI
            Operation.Enabled = SelectedGroup.IsBooleanConstruct;
            RaiseGroupModified(SelectedGroup);
        }
Esempio n. 5
0
        /// <summary>
        /// Handles the visibility changing.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void VisibilityChanged(Foundation.NSObject sender)
        {
            // Save an undo point
            DesignSurface.SaveUndoPoint();

            // Swap Visibility
            SelectedShape.Visible = !SelectedShape.Visible;
            RaiseShapeModified();

            // Update GUI
            VisibleButton.Image = NSImage.ImageNamed((SelectedShape.Visible) ? "IconVisible" : "IconInvisible");
        }
        public override void Load(XElement root)
        {
            Assert.ArgumentNotNull(root, nameof(root));

            DesignSurface.Clear();

            LoadState(root);

            SetModifiedFlag(false);
            DesignSurface.ClearJournal();
            DesignSurface.AddToJournal();
        }
Esempio n. 7
0
        protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
        {
            Debug.Assert(file == this.PrimaryFile);

            _stream = new MemoryStream();
            stream.CopyTo(_stream);
            stream.Position = 0;

            if (designer == null)
            {
                // initialize designer on first load
                designer         = new DesignSurface();
                this.UserContent = designer;
                InitPropertyEditor();
            }
            this.UserContent = designer;
            if (outline != null)
            {
                outline.Root = null;
            }
            using (XmlTextReader r = new XmlTextReader(stream)) {
                XamlLoadSettings settings = new XamlLoadSettings();
                settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly);
                settings.CustomServiceRegisterFunctions.Add(
                    delegate(XamlDesignContext context) {
                    context.Services.AddService(typeof(IUriContext), new FileUriContext(this.PrimaryFile));
                    context.Services.AddService(typeof(IPropertyDescriptionService), new PropertyDescriptionService(this.PrimaryFile));
                    context.Services.AddService(typeof(IEventHandlerService), new CSharpEventHandlerService(this));
                    context.Services.AddService(typeof(ITopLevelWindowService), new WpfAndWinFormsTopLevelWindowService());
                    context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService());
                });
                settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile);
                try{
                    settings.ReportErrors = UpdateTasks;
                    designer.LoadDesigner(r, settings);

                    designer.ContextMenuOpening += (sender, e) => MenuService.ShowContextMenu(e.OriginalSource as UIElement, designer, "/AddIns/WpfDesign/Designer/ContextMenu");

                    if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null)
                    {
                        outline.Root = OutlineNode.Create(designer.DesignContext.RootItem);
                    }

                    propertyGridView.PropertyGrid.SelectedItems = null;
                    designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged;
                    designer.DesignContext.Services.GetService <UndoService>().UndoStackChanged += OnUndoStackChanged;
                }
                catch
                {
                    this.UserContent = new WpfDocumentError();
                }
            }
        }
Esempio n. 8
0
        private IDesignSurfaceExt2 GetCurrentIDesignSurface()
        {
            int index = this.tabControl1.SelectedIndex;

            if (index >= _mgr.DesignSurfaces.Count)
            {
                return(null);
            }
            DesignSurface surface = _mgr.DesignSurfaces[index];

            return(surface as IDesignSurfaceExt2);
        }
Esempio n. 9
0
        /// <summary>
        /// Handles the horizontal shadow offset changing.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void HorizontalShadowOffsetChanged(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Save new value
            SelectedStyle.FillShadow.HorizontalOffset = HorizontalShadowOffsetSlider.FloatValue;

            // Update UI
            HorizontalShadowOffsetValue.StringValue = HorizontalShadowOffsetSlider.IntValue.ToString();
            RaiseShapeModified();
        }
Esempio n. 10
0
        /// <summary>
        /// Handles the shadow changing.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void ShadowChanged(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Save new value
            SelectedStyle.HasFillShadow = (ShadowCheckbox.IntValue == 1);

            // Update UI
            ShowCurrentShadowColor();
            RaiseShapeModified();
        }
        /// <summary>
        /// Duplicates the point.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void DuplicatePoint(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Duplicate control point
            SelectedGradient.DuplicateSelectedControlPoint();

            // Update UI
            RaiseGradientModified(SelectedGradient);
            RaiseShapeModified();
        }
        /// <summary>
        /// Handles the radius changing.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void RadiusChanged(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Save new value
            SelectedRoundRect.CornerRadius = RadiusSlider.FloatValue;

            // Update UI
            RadiusValue.StringValue = RadiusSlider.IntValue.ToString();
            RaiseShapeModified();
        }
        public void SetUpFixture()
        {
            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                Form form = (Form)host.RootComponent;
                form.ClientSize = new Size(200, 300);

                PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(form);
                PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                namePropertyDescriptor.SetValue(form, "MainForm");

                // Add list view.
                ListView listView = (ListView)host.CreateComponent(typeof(ListView), "listView1");
                listView.TabIndex   = 0;
                listView.Location   = new Point(0, 0);
                listView.ClientSize = new Size(200, 100);
                descriptors         = TypeDescriptor.GetProperties(listView);
                PropertyDescriptor descriptor = descriptors.Find("UseCompatibleStateImageBehavior", false);
                descriptor.SetValue(listView, true);
                descriptor = descriptors.Find("View", false);
                descriptor.SetValue(listView, View.Details);
                form.Controls.Add(listView);

                // Add column headers.
                columnHeader1 = (ColumnHeader)host.CreateComponent(typeof(ColumnHeader), "columnHeader1");
                descriptors   = TypeDescriptor.GetProperties(columnHeader1);
                descriptor    = descriptors.Find("Text", false);
                descriptor.SetValue(columnHeader1, "columnHeader1");
                listView.Columns.Add(columnHeader1);

                columnHeader2 = (ColumnHeader)host.CreateComponent(typeof(ColumnHeader), "columnHeader2");
                descriptors   = TypeDescriptor.GetProperties(columnHeader2);
                descriptor    = descriptors.Find("Text", false);
                descriptor.SetValue(columnHeader2, "columnHeader2");
                listView.Columns.Add(columnHeader2);

                DesignerSerializationManager  designerSerializationManager = new DesignerSerializationManager(host);
                IDesignerSerializationManager serializationManager         = (IDesignerSerializationManager)designerSerializationManager;
                using (designerSerializationManager.CreateSession()) {
                    // Add list view item with 3 sub items.
                    ListViewItem item = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[] { "listItem1" }, "listViewItem1", false);
                    item.SubItems.Add("subItem1");
                    item.SubItems.Add("subItem2");
                    item.SubItems.Add("subItem3");
                    listView.Items.Add(item);

                    RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
                    generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, designerSerializationManager, String.Empty, 1);
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Handles the blur effect changing.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void BlurChanged(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Save new value
            SelectedStyle.HasFrameBlur = (BlurCheckbox.IntValue == 1);

            // Update UI
            HorizontalBlurSlider.Enabled = SelectedStyle.HasFrameBlur;
            VerticalBlurSlider.Enabled   = SelectedStyle.HasFrameBlur;
            RaiseShapeModified();
        }
        /// <summary>
        /// Initialize this instance.
        /// </summary>
        public void Initialize()
        {
            // Wireup events
            XField.EditingEnded += (sender, e) =>
            {
                var value = SelectedRect.Left;
                if (float.TryParse(XField.StringValue, out value))
                {
                    DesignSurface.SaveUndoPoint();
                    var width = SelectedRect.Width;
                    SelectedRect.Left  = value;
                    SelectedRect.Right = SelectedRect.Left + width;
                    RaisePropertyModified();
                }
            };

            YField.EditingEnded += (sender, e) =>
            {
                var value = SelectedRect.Top;
                if (float.TryParse(YField.StringValue, out value))
                {
                    DesignSurface.SaveUndoPoint();
                    var height = SelectedRect.Height;
                    SelectedRect.Top    = value;
                    SelectedRect.Bottom = SelectedRect.Top + height;
                    RaisePropertyModified();
                }
            };

            WidthField.EditingEnded += (sender, e) =>
            {
                var value = SelectedRect.Width;
                if (float.TryParse(WidthField.StringValue, out value))
                {
                    DesignSurface.SaveUndoPoint();
                    SelectedRect.Width = value;
                    RaisePropertyModified();
                }
            };

            HeightField.EditingEnded += (sender, e) =>
            {
                var value = SelectedRect.Height;
                if (float.TryParse(HeightField.StringValue, out value))
                {
                    DesignSurface.SaveUndoPoint();
                    SelectedRect.Height = value;
                    RaisePropertyModified();
                }
            };
        }
Esempio n. 16
0
        public Control GetControl()
        {
            ServiceContainer serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IDesignerEventService), new DesignerEventService());
            serviceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService());
            _toolboxService = new CustomToolboxService();
            serviceContainer.AddService(typeof(IToolboxService), _toolboxService);

            DesignSurface surface = new DesignSurface(serviceContainer);

            _host = (IDesignerHost)surface.GetService(typeof(IDesignerHost));

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), new Services.EventBindingService(surface));

            _menuCommandService = new MenuCommandService(surface);
            serviceContainer.AddService(typeof(IMenuCommandService), _menuCommandService);

            //surface.BeginLoad(typeof(Form));
            _CodeDomHostLoader = new Loader.CodeDomHostLoader();
            surface.BeginLoad(_CodeDomHostLoader);

            Control designerContorl = (Control)surface.View;


            designerContorl.BackColor = Color.Aqua;
            designerContorl.Dock      = DockStyle.Fill;
            //获取root组件
            var designerHost = (IDesignerHost)this._host;

            if (designerHost != null)
            {
                rootComponent = (Form)designerHost.RootComponent;
            }

            rootComponent.FormBorderStyle = FormBorderStyle.None;

            #region 初始化窗体大小

            //- set the Size
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(designerContorl);
            //- Sets a PropertyDescriptor to the specific property.
            PropertyDescriptor pdS = pdc.Find("Size", false);
            if (null != pdS)
            {
                pdS.SetValue(_host.RootComponent, new Size(800, 480));
            }
            #endregion

            return(designerContorl);
        }
Esempio n. 17
0
        /// <summary>
        /// Initialize this instance.
        /// </summary>
        public void Initialize()
        {
            // Wire-up events
            NameField.EditingEnded += (sender, e) =>
            {
                // Save undo point
                DesignSurface.SaveUndoPoint();

                // Save and validate
                SelectedPortfolio.Name = NameField.StringValue;
                SelectedPortfolio.Name = Kimono.MakeValidItemName("Portfolio", SelectedPortfolio.Name);

                // Update UI
                NameField.StringValue = SelectedPortfolio.Name;
                RaisePortfolioModified();
            };

            NamespaceField.EditingEnded += (sender, e) =>
            {
                // Save undo point
                DesignSurface.SaveUndoPoint();

                SelectedPortfolio.Namespace = NamespaceField.StringValue;
                RaisePortfolioModified();
            };

            AuthorField.EditingEnded += (sender, e) =>
            {
                // Save undo point
                DesignSurface.SaveUndoPoint();

                SelectedPortfolio.Author = AuthorField.StringValue;
                RaisePortfolioModified();
            };

            CopyrightField.TextChanged += (text) =>
            {               // Save undo point based on edit state
                if (FirstChange)
                {
                    DesignSurface.SaveUndoPoint();
                    FirstChange = false;
                }
                else
                {
                    DesignSurface.ReplaceUndoPoint();
                }

                SelectedPortfolio.Copyright = text;
                RaisePortfolioModified();
            };
        }
        public void SetUpFixture()
        {
            resourceWriter   = new MockResourceWriter();
            componentCreator = new MockComponentCreator();
            componentCreator.SetResourceWriter(resourceWriter);

            resourceWriter2   = new MockResourceWriter();
            componentCreator2 = new MockComponentCreator();
            componentCreator2.SetResourceWriter(resourceWriter2);

            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                host.AddService(typeof(IResourceService), componentCreator);

                Form form = (Form)host.RootComponent;
                form.ClientSize = new Size(200, 300);

                PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(form);
                PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                namePropertyDescriptor.SetValue(form, "MainForm");

                // Add picture box
                PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
                pictureBox.Location = new Point(0, 0);
                bitmap              = new Bitmap(10, 10);
                pictureBox.Image    = bitmap;
                pictureBox.Size     = new Size(100, 120);
                pictureBox.TabIndex = 0;
                form.Controls.Add(pictureBox);

                // Add bitmap to form.
                form.BackgroundImage = new Bitmap(10, 10);

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }

                // Check that calling the GenerateInitializeComponentMethodBody also generates a resource file.
                host.RemoveService(typeof(IResourceService));
                host.AddService(typeof(IResourceService), componentCreator2);

                serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
                    serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
                }
            }
        }
Esempio n. 19
0
 void UpdateDesign()
 {
     OutlineRoot = null;
     using (var xmlReader = XmlReader.Create(new StringReader(Text))) {
         DesignSurface.LoadDesigner(xmlReader, null);
     }
     if (DesignContext.RootItem != null)
     {
         OutlineRoot = OutlineNode.Create(DesignContext.RootItem);
         UndoService.UndoStackChanged += new EventHandler(UndoService_UndoStackChanged);
     }
     RaisePropertyChanged("SelectionService");
     RaisePropertyChanged("XamlErrorService");
 }
Esempio n. 20
0
		protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
		{
			Debug.Assert(file == this.PrimaryFile);
			
			_stream = new MemoryStream();
			stream.CopyTo(_stream);
			stream.Position = 0;
			
			if (designer == null) {
				// initialize designer on first load
				designer = new DesignSurface();
				this.UserContent = designer;
				InitPropertyEditor();
			}
			this.UserContent=designer;
			if (outline != null) {
				outline.Root = null;
			}
			using (XmlTextReader r = new XmlTextReader(stream)) {
				XamlLoadSettings settings = new XamlLoadSettings();
				settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly);
				settings.CustomServiceRegisterFunctions.Add(
					delegate(XamlDesignContext context) {
						context.Services.AddService(typeof(IUriContext), new FileUriContext(this.PrimaryFile));
						context.Services.AddService(typeof(IPropertyDescriptionService), new PropertyDescriptionService(this.PrimaryFile));
						context.Services.AddService(typeof(IEventHandlerService), new CSharpEventHandlerService(this));
						context.Services.AddService(typeof(ITopLevelWindowService), new WpfAndWinFormsTopLevelWindowService());
						context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService());
					});
				settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile);
				try{
					settings.ReportErrors=UpdateTasks;
					designer.LoadDesigner(r, settings);
					
					designer.ContextMenuOpening += (sender, e) => MenuService.ShowContextMenu(e.OriginalSource as UIElement, designer, "/AddIns/WpfDesign/Designer/ContextMenu");
					
					if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) {
						outline.Root = OutlineNode.Create(designer.DesignContext.RootItem);
					}
					
					propertyGridView.PropertyGrid.SelectedItems = null;
					designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged;
					designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged;
				}
				catch
				{
					this.UserContent=new WpfDocumentError();
				}
			}
		}
        public static DragFileToDesignPanelHelper Install(DesignSurface designSurface, Func <DesignContext, DragEventArgs, DesignItem[]> createItems)
        {
            var helper = new DragFileToDesignPanelHelper();

            helper._createItems = createItems;
            helper._designPanel = designSurface._designPanel as DesignPanel;

            helper._designPanel.AllowDrop  = true;
            helper._designPanel.DragOver  += helper.designPanel_DragOver;
            helper._designPanel.Drop      += helper.designPanel_Drop;
            helper._designPanel.DragLeave += helper.designPanel_DragLeave;

            return(helper);
        }
Esempio n. 22
0
        public void DesignSurface_GetService_InvokeWithServiceProvider_ReturnsExpected()
        {
            var service             = new object();
            var mockServiceProvider = new Mock <IServiceProvider>(MockBehavior.Strict);

            mockServiceProvider
            .Setup(p => p.GetService(typeof(int)))
            .Returns(service)
            .Verifiable();
            var surface = new DesignSurface(mockServiceProvider.Object);

            Assert.Same(service, surface.GetService(typeof(int)));
            mockServiceProvider.Verify(p => p.GetService(typeof(int)), Times.Once());
        }
Esempio n. 23
0
        void CreateDesignSurface()
        {
            surface                     = new DesignSurface();
            designerHost                = surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
            rootDesignControl           = designerHost.CreateComponent(typeof(UserControl)) as Control;
            rootDesignControl.Dock      = DockStyle.Fill;
            rootDesignControl.BackColor = Color.AliceBlue;
            Control c = surface.View as Control;

            c.Dock      = DockStyle.Fill;
            c.BackColor = Color.White;
            c.Location  = new Point(15, 25);
            c.Parent    = DesignContainer;
        }
Esempio n. 24
0
        public override void Paint(PaintEventArgs pe)
        {
            if (null == _ctrl.Site)
            {
                return;
            }

            if (null == _adornerPanel)
            {
                return;
            }

            if (object.ReferenceEquals(_selectionService.PrimarySelection, _ctrl))
            {
                if (_ctrl.Parent == null)
                {
                    return;
                }
                Point         pt   = _ctrl.Parent.PointToScreen(_ctrl.Location);
                DesignSurface ds   = _ctrl.Site.GetService(typeof(DesignSurface)) as DesignSurface;
                Control       view = ds.View as Control;
                if (null != view)
                {
                    pt = view.PointToClient(pt);
                }
                Point scPt = GetScrollPoint();
                pt.X += scPt.X;
                pt.Y += scPt.Y;
                pt    = new Point(pt.X, pt.Y - AdornerPanel.PanelHeight);

                if (_adornerPanel.ItemList.Count == 0)
                {
                    ISuspensionable supspension = _ctrl as ISuspensionable;
                    if (null != supspension)
                    {
                        SuspensionItem[] items = supspension.ListSuspensionItems();
                        for (int i = 0; i < items.Length; i++)
                        {
                            if (null != items[i])
                            {
                                _adornerPanel.AddItem(items[i]);
                            }
                        }
                    }
                }
                _adornerPanel.Location = pt;
                _adornerPanel.Paint(pe.Graphics);
                _clipRectangle = pe.ClipRectangle;
            }
        }
Esempio n. 25
0
 /// <summary>
 /// Initialize this instance.
 /// </summary>
 public void Initialize()
 {
     // Wireup events
     ValueField.EditingEnded += (sender, e) =>
     {
         var value = SelectedNumber.Value;
         if (float.TryParse(ValueField.StringValue, out value))
         {
             DesignSurface.SaveUndoPoint();
             SelectedNumber.Value = value;
             RaisePropertyModified();
         }
     };
 }
Esempio n. 26
0
        //
        public DiagramDesignerHolder()
        {
            InitializeComponent();
            btOK.BringToFront();
            btCancel.BringToFront();
            _undoEngine = new UndoEngine2();
            //
            dsf = new DesignSurface(typeof(DiagramViewer));
            Control control = dsf.View as Control;             //DesignerFrame

            splitContainer1.Panel2.Controls.Add(control);
            control.Dock    = DockStyle.Fill;
            control.Visible = true;
            splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved);
            this.Resize += new EventHandler(designview_Resize);
            splitContainer1.SplitterWidth = 3;
            //
            IDesignerHost host = (IDesignerHost)dsf.GetService(typeof(IDesignerHost));

            root      = (DiagramViewer)host.RootComponent;
            root.Dock = DockStyle.Fill;
            root.AssignHolder(this);
            //
            host.AddService(typeof(PropertyGrid), propertyGrid1);
            host.AddService(typeof(INameCreationService), new NameCreation());
            //
            selectionService = (ISelectionService)dsf.GetService(typeof(ISelectionService));
            if (selectionService != null)
            {
                selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
            }
            IComponentChangeService componentChangeService = (IComponentChangeService)dsf.GetService(typeof(IComponentChangeService));

            componentChangeService.ComponentAdded    += new ComponentEventHandler(componentChangeService_ComponentAdded);
            componentChangeService.ComponentRemoving += new ComponentEventHandler(componentChangeService_ComponentRemoving);
            componentChangeService.ComponentRemoved  += new ComponentEventHandler(componentChangeService_ComponentRemoved);
            componentChangeService.ComponentChanged  += new ComponentChangedEventHandler(componentChangeService_ComponentChanged);
            //
            root.ControlRemoved += new ControlEventHandler(root_ControlRemoved);
            //
            _msgFilter = new DesignMessageFilter(dsf);
            Application.AddMessageFilter(_msgFilter);
            //
            propertyGrid1.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid1_PropertyValueChanged);
            propertyGrid1.HelpVisible           = false;
            propertyGrid1.PropertySort          = PropertySort.Alphabetical;
            propertyGrid1.SelectedObject        = root;
            //
        }
Esempio n. 27
0
        /// <summary>
        /// Handles the fill changing.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void FillChanged(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Inform caller of change
            SelectedStyle.HasFill = (FillCheckbox.IntValue == 1);
            RaiseShapeModified();

            // Update GUI
            FillColor.Enabled     = (SelectedStyle.HasFill && SelectedStyle.FillColor == null);
            OpacitySlider.Enabled = (SelectedStyle.HasFill && SelectedStyle.FillColor == null);
            OpacityValue.Enabled  = (SelectedStyle.HasFill && SelectedStyle.FillColor == null);
            BlendMode.Enabled     = SelectedStyle.HasFill;
        }
Esempio n. 28
0
        public StationMapForm()
        {
            InitializeComponent();
            persistState = new PersistWindowState(registryPath, this);
            DesignSurface     surface   = new DesignSurface();
            IServiceContainer container = surface.GetService(typeof(IServiceContainer)) as IServiceContainer;

            _menuCommandService = new MenuCommandService(surface);
            if (container != null)
            {
                container.AddService(typeof(IMenuCommandService), _menuCommandService);
            }
            DrawForm();
            //InitStationDeviceType();
        }
Esempio n. 29
0
 public Document(string fileName, Workspace workspace)
 {
     if (workspace == null)
     {
         throw new ArgumentNullException("workspace");
     }
     if (fileName == null)
     {
         throw new ArgumentNullException("fileName");
     }
     _fileName  = fileName;
     _workspace = workspace;
     _loaded    = false;
     _surface   = new DesignSurface(_workspace.Services);
 }
        private IntPtr CreateDesignerView(IVsHierarchy hierarchy, uint itemid, IVsTextLines textLines, ref string editorCaption, ref Guid cmdUI, string documentMoniker)
        {
            // Request the Designer Service
            IVSMDDesignerService designerService = (IVSMDDesignerService)GetService(typeof(IVSMDDesignerService));

            try
            {
                // Get the service provider
                IOleServiceProvider provider = serviceProvider.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;

                // Create loader for the designer
                FrameXmlDesignerLoader designerLoader = new FrameXmlDesignerLoader(textLines, documentMoniker, itemid);

                // Create the designer using the provider and the loader
                IVSMDDesigner designer = designerService.CreateDesigner(provider, designerLoader);

#if !HIDE_FRAME_XML_PANE
                // Retrieve the design surface
                DesignSurface designSurface = (DesignSurface)designer;

                // Create pane with this surface
                FrameXmlPane frameXmlPane = new FrameXmlPane(designSurface);

                designerLoader.InitializeFrameXmlPane(frameXmlPane);

                // Get command guid from designer
                cmdUI         = frameXmlPane.CommandGuid;
                editorCaption = " [Design]";

                // Return FrameXmlPane
                return(Marshal.GetIUnknownForObject(frameXmlPane));
#else
                object view = designer.View;

                cmdUI         = designer.CommandGuid;
                editorCaption = " [Design]";

                designerLoader.InitializeFrameXmlPane(null);
                // Return view
                return(Marshal.GetIUnknownForObject(view));
#endif
            }
            catch (Exception ex)
            {
                // Just rethrow for now
                throw;
            }
        }
        /// <summary>
        /// Handles the value from script changing.
        /// </summary>
        /// <param name="sender">Sender.</param>
        partial void ValueFromScriptChanged(Foundation.NSObject sender)
        {
            // Save undo point
            DesignSurface.SaveUndoPoint();

            // Save new value
            SelectedProperty.GetsValueFromScript = (ValueFromScriptCheckbox.IntValue == 1);
            ObiScriptEngine.ClearResults();
            if (SelectedProperty.GetsValueFromScript)
            {
                SelectedProperty.Usage = KimonoPropertyUsage.GlobalVariable;
            }

            // Update UI
            RaisePropertyModified();
        }
        public void ExtenderProviderService_AddExtenderProvider_Invoke_Success()
        {
            var    surface = new DesignSurface();
            object service = surface.GetService(typeof(IExtenderListService));
            IExtenderListService     listService     = Assert.IsAssignableFrom <IExtenderListService>(service);
            IExtenderProviderService providerService = Assert.IsAssignableFrom <IExtenderProviderService>(service);
            var mockExtenderProvider1 = new Mock <IExtenderProvider>(MockBehavior.Strict);
            var mockExtenderProvider2 = new Mock <IExtenderProvider>(MockBehavior.Strict);

            providerService.AddExtenderProvider(mockExtenderProvider1.Object);
            Assert.Equal(new IExtenderProvider[] { mockExtenderProvider1.Object }, listService.GetExtenderProviders());

            // Add another.
            providerService.AddExtenderProvider(mockExtenderProvider2.Object);
            Assert.Equal(new IExtenderProvider[] { mockExtenderProvider1.Object, mockExtenderProvider2.Object }, listService.GetExtenderProviders());
        }
Esempio n. 33
0
        /// <summary>
        /// Load a markup file into the designer
        /// </summary>
        /// <param name="markupFileName"></param>
        /// <returns></returns>
        public Boolean LoadWorkflow(String markupFileName)
        {
            //remove the current workflow from the designer
            //if there is one
            ClearWorkflow();

            //create the design surface
            _designSurface = new DesignSurface();

            //pass the markup file name to the loader
            _wfLoader.MarkupFileName  = markupFileName;
            _wfLoader.NewWorkflowType = null;

            //complete the loading
            return(CommonWorkflowLoading());
        }
        public DesignAidsProvider(DesignSurface designSurface)
        {
            DesignSurface = designSurface;
            DesignSurface.Loaded += DesignSurfaceOnLoaded;

            SelectionAdorners = new Dictionary<ICanvasItem, SelectionAdorner>();

            EdgeAdorners = new Dictionary<Edge, EdgeAdorner>();

            PlaneOperation = PlaneOperation.Resize;
            DragOperationHost = new DragOperationHost(DesignSurface);
            DragOperationHost.DragStarted += DragOperationHostOnDragStarted;
            DragOperationHost.DragEnd += DragOperationHostOnDragEnd;

            SnappingEngine = new CanvasItemSnappingEngine(4);
            var snappedEdges = SnappingEngine.SnappedEdges;
            ((INotifyCollectionChanged)snappedEdges).CollectionChanged += SnappedEdgesOnCollectionChanged;

            DragOperationHost.SnappingEngine = SnappingEngine;
        }
Esempio n. 35
0
		private void InitializeRunner ()
		{
			StartGuiThread ();
			RunMWFThread ();
            while (_mwfContainer == null) {}
			while (!_mwfContainer.IsHandleCreated) { } // wait for the mwf handle


			// Hopefully by the time LoadGui is done the MWF Application.Run
			// will be done with whatever it's doing, because else strange things
			// might happen.
			Gtk.Application.Invoke (delegate { 
				InitializeGTK ();
			});
            while (_gtkContainer == null) {}
			while (_gtkContainer.Handle == IntPtr.Zero) { } // wait for the gtk handle

			bool parented = false;
			Gtk.Application.Invoke ( delegate { 
				Gdk.Window window = Gdk.Window.ForeignNew ((uint) _mwfContainer.Handle);
				window.Reparent (_gtkContainer.GdkWindow, 0, 0);
				parented = true;
			});
			while (!parented) { }

			EventHandler loadSurfaceDelegate = delegate {
				DesignSurface surface = new DesignSurface ();
				((IServiceContainer)surface.GetService (typeof (IServiceContainer))).AddService (typeof (ITypeResolutionService),
																								 new TypeResolutionService ());
				surface.BeginLoad (new MDDesignerLoader (_designerFile));
				if (surface.IsLoaded) {
					_mwfContainer.Controls.Add ((Control)surface.View);
					_mwfContainer.Refresh ();
				}
			};
			_mwfContainer.Invoke (loadSurfaceDelegate);

			_gtkContainer.SizeAllocated += delegate (object o, SizeAllocatedArgs args) {
				EventHandler resizeDelegate = delegate {
					_mwfContainer.Width = args.Allocation.Width;
					_mwfContainer.Height = args.Allocation.Height;
				};
				_mwfContainer.Invoke (resizeDelegate);
			};	

			EventHandler resizeNow = delegate {
				_mwfContainer.Width = _gtkContainer.Allocation.Width;
				_mwfContainer.Height = _gtkContainer.Allocation.Height;
			};
			_mwfContainer.Invoke (resizeNow);
		}
		private void OnDesignSurfaceCreated (DesignSurface surface)
		{
			if (DesignSurfaceCreated != null)
				DesignSurfaceCreated (this, new DesignSurfaceEventArgs (surface));
			
			// monitor disposing
			surface.Disposed += new EventHandler (OnDesignSurfaceDisposed);
			
			DesignerEventService eventService = GetService (typeof (IDesignerEventService)) as DesignerEventService;
			if (eventService != null)
				eventService.RaiseDesignerCreated (surface.GetService (typeof (IDesignerHost)) as IDesignerHost);
		}
		// The CreateDesignSurfaceCore method is called by both CreateDesignSurface methods.
		// It is the implementation that actually creates the design surface. The default
		// implementation just returns a new DesignSurface. You may override this method to provide
		// a custom object that derives from the DesignSurface class.
		//
		protected virtual DesignSurface CreateDesignSurfaceCore (IServiceProvider parentProvider)
		{
			DesignSurface surface = new DesignSurface (parentProvider);
			OnDesignSurfaceCreated (surface);
			return surface;
		}
	public void CopyTo(DesignSurface[] array, int index) {}
	// Constructors
	public ActiveDesignSurfaceChangedEventArgs(DesignSurface oldSurface, DesignSurface newSurface) {}
		public void CopyTo (DesignSurface[] array, int index)
		{
			((ICollection) this).CopyTo (array, index);
		}
 public DesignerKeyBindings(DesignSurface surface)
 {
     Debug.Assert(surface != null);
     this._surface = surface;
     _bindings = new Collection<KeyBinding>();
 }
Esempio n. 42
0
        private void ClearWorkflow()
        {
            if (_designSurface != null)
            {
                IDesignerHost designer = _designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (designer != null)
                {
                    if (designer.Container.Components.Count > 0)
                    {
                        _wfLoader.RemoveFromDesigner(designer, designer.RootComponent as Activity);
                    }
                }

                _designSurface.Dispose();
                _designSurface = null;
            }

            if (_wfView != null)
            {
                ISelectionService selectionService = ((IServiceProvider)_wfView).GetService(typeof(ISelectionService)) as ISelectionService;
                if (selectionService != null)
                {
                    selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged);
                }

                Controls.Remove(_wfView);
                _wfView.Dispose();
                _wfView = null;
            }

            if (_toolboxControl != null)
            {
                Controls.Remove(_toolboxControl);
            }
        }
	// Constructors
	public DesignSurfaceEventArgs(DesignSurface surface) {}
Esempio n. 44
0
 public FocusNavigator(DesignSurface surface)
 {
     this._surface=surface;
 }
Esempio n. 45
0
		protected DesignItem CreateGridContextWithDesignSurface(string xaml)
		{
			var surface = new DesignSurface();
			var xamlWithGrid=@"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
            " + xaml + "</Grid>";
			surface.LoadDesigner(new XmlTextReader(new StringReader(xamlWithGrid)), new XamlLoadSettings());
			Assert.IsNotNull(surface.DesignContext.RootItem);
			return surface.DesignContext.RootItem;
		}
Esempio n. 46
0
		protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
		{
			wasChangedInDesigner = false;
			Debug.Assert(file == this.PrimaryFile);
			SD.AnalyticsMonitor.TrackFeature(typeof(WpfViewContent), "Load");
			
			_stream = new MemoryStream();
			stream.CopyTo(_stream);
			stream.Position = 0;
			
			if (designer == null) {
				// initialize designer on first load
				designer = new DesignSurface();
				this.UserContent = designer;
				InitPropertyEditor();
				InitWpfToolbox();
			}
			this.UserContent = designer;
			if (outline != null) {
				outline.Root = null;
			}
			
			
			using (XmlTextReader r = new XmlTextReader(stream)) {
				XamlLoadSettings settings = new XamlLoadSettings();
				settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly);
				settings.CustomServiceRegisterFunctions.Add(
					delegate(XamlDesignContext context) {
						context.Services.AddService(typeof(IUriContext), new FileUriContext(this.PrimaryFile));
						context.Services.AddService(typeof(IPropertyDescriptionService), new PropertyDescriptionService(this.PrimaryFile));
						context.Services.AddService(typeof(IEventHandlerService), new SharpDevelopEventHandlerService(this));
						context.Services.AddService(typeof(ITopLevelWindowService), new WpfAndWinFormsTopLevelWindowService());
						context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService());
					});
				settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile);
				settings.CurrentProjectAssemblyName = SD.ProjectService.CurrentProject.AssemblyName;
				
				try
				{
					if (WpfEditorOptions.EnableAppXamlParsing)
					{
						var appXaml = SD.ProjectService.CurrentProject.Items.FirstOrDefault(x => x.FileName.GetFileName().ToLower() == ("app.xaml"));
						if (appXaml != null)
						{
							var f = appXaml as FileProjectItem;
							OpenedFile a = SD.FileService.GetOrCreateOpenedFile(f.FileName);

							var xml = XmlReader.Create(a.OpenRead());
							var doc = new XmlDocument();
							doc.Load(xml);
							var node = doc.FirstChild.ChildNodes.Cast<XmlNode>().FirstOrDefault(x => x.Name == "Application.Resources");

							foreach (XmlAttribute att in doc.FirstChild.Attributes.Cast<XmlAttribute>().ToList())
							{
								if (att.Name.StartsWith("xmlns")) {
									foreach (var childNode in node.ChildNodes.OfType<XmlNode>()) {
										childNode.Attributes.Append(att);
									}
								}
							}

							var appXamlXml = XmlReader.Create(new StringReader(node.InnerXml));
							var appxamlContext = new XamlDesignContext(appXamlXml, settings);
							
							//var parsed = XamlParser.Parse(appXamlXml, appxamlContext.ParserSettings);
							var dict = (ResourceDictionary) appxamlContext.RootItem.Component;// parsed.RootInstance;
							designer.DesignPanel.Resources.MergedDictionaries.Add(dict);
						}
					}
				}
				catch (Exception ex)
				{
					LoggingService.Error("Error in loading app.xaml", ex);
				}

				try
				{
					settings.ReportErrors = UpdateTasks;
					designer.LoadDesigner(r, settings);
					
					designer.DesignPanel.ContextMenuHandler = (contextMenu) => {
						var newContextmenu = new ContextMenu();
						var sdContextMenuItems = MenuService.CreateMenuItems(newContextmenu, designer, "/AddIns/WpfDesign/Designer/ContextMenu", "ContextMenu");
						foreach(var entry in sdContextMenuItems)
							newContextmenu.Items.Add(entry);
						newContextmenu.Items.Add(new Separator());
						
						var items = contextMenu.Items.Cast<Object>().ToList();
						contextMenu.Items.Clear();
						foreach(var entry in items)
							newContextmenu.Items.Add(entry);
						
						designer.DesignPanel.ContextMenu = newContextmenu;
					};
					
					if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) {
						outline.Root = OutlineNode.Create(designer.DesignContext.RootItem);
					}
					
					propertyGridView.PropertyGrid.SelectedItems = null;
					designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged;
					designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged;
				} catch (Exception e) {
					this.UserContent = new WpfDocumentError(e);
				}
			}
		}