Пример #1
0
		private void AddPropertiesToParts(UimlDocument doc)
		{
			ArrayList styles = doc.UInterface.UStyle;
			// TODO: support multiple structures
			Structure structure = (Structure) doc.UInterface.UStructure[0];

			foreach (LayoutProperty lp in m_properties.Values)
			{
				Part part = structure.SearchPart(lp.PartName);
				Property prop;
				
				// remove existing, absolute layout properties

				// check for inline properties
				prop = part.GetProperty(lp.Name);
				if (prop != null)
					part.RemoveProperty(prop);
				//
				// check for properties in style section
				foreach (Style s in styles)
				{
					prop = s.SearchProperty(lp.PartName, lp.Name);
					if (prop != null)
						s.RemoveProperty(prop);
				}

				// add the layout property
				part.AddProperty(lp);
			}
		}
Пример #2
0
		public override IRenderedInstance PreRender(UimlDocument uimlDoc)
		{
			try
			{
				m_topWindow = new WxRenderedInstance("Uiml container");

				Structure uiStruct   = (Structure)uimlDoc.UInterface.UStructure[0];
				Style     uiStyle    = (Style)uimlDoc.UInterface.UStyle[0];
				Behavior  uiBehavior = null;
				try{
					uiBehavior = (Behavior)uimlDoc.UInterface.UBehavior[0];
				}catch(Exception e){ /* no behavior specified */ }

				Top = uiStruct.Top;
				Voc = uimlDoc.SearchPeers(NAME).GetVocabulary();
				Console.WriteLine("Calling TopFrame...");
				Console.WriteLine("In Render; TopFrame is {0}", m_topWindow.TopFrame);
				Window c = Render(uiStruct.Top, uiStyle, m_topWindow.TopFrame);
				//Render has filled the part-tree with the concrete object references
				//to the individual widgets, now attach the behavior
				//c.Reparent((Window)m_topWindow.TopFrame);
				return m_topWindow;
			}
				catch(NullReferenceException nrfe)
				{
					Console.WriteLine("The Rendering Engine says: Check the input documents, they seem to be invalid");
					Console.WriteLine(nrfe);
					throw nrfe;
				}
		}
Пример #3
0
		public static int Main (string[] args)
		{
			UimlDocument uimlDoc = new UimlDocument("check.uiml");
			CheckTest ct = new CheckTest();
			uimlDoc.Connect(ct);
			IRenderer renderer = (new BackendFactory()).CreateRenderer(uimlDoc.Vocabulary);
		   IRenderedInstance ri = renderer.Render(uimlDoc);
			ri.ShowIt();
			return 0;
		}
Пример #4
0
		public void InitializeProperties(UimlDocument doc, IRenderer r)
		{
			AddPropertiesToParts(doc);

			foreach (LayoutProperty lp in m_properties.Values)
			{
				int renderedValue = (int) lp.GetCurrentValue(r.PropertySetter, null);

				// will be converted to string automatically by LayoutProperty class!
				lp.InitializeVariable((double) renderedValue);
			}
		}
Пример #5
0
		public void Insert(string pattern, UimlDocument doc)
		{
			//TODO: maintain order of pattern while inserting
			//TODO: replace "<!-- pattern -->" with template
			 
			Uiml.Part parent = workingDoc.SearchPart(pattern);
			parent.AddChild( ((Structure)doc.UInterface.UStructure[0]).Top);
			ArrayList properties = ((Style)doc.UInterface.UStyle[0]).Children;
			IEnumerator enumProps = properties.GetEnumerator();
			while(enumProps.MoveNext())
			{
				((Style)workingDoc.UInterface.UStyle[0]).Children.Add((Property)enumProps.Current);
			}
		}
Пример #6
0
        private void LoadFrontEnd()
        {
			try //try to load a GUI as front-end
			{
                UimlDocument feUimlDoc = new UimlDocument(m_frontendFile);
				renderer =  (new BackendFactory()).CreateRenderer(feUimlDoc.Vocabulary);
                IRenderedInstance instance = renderer.Render(feUimlDoc);
                ExternalLibraries.Instance.Add(m_frontendLib);
				feUimlDoc.Connect(this);
                // add to the list
                renderedUIs.Add(m_frontendFile, instance);
                instance.ShowIt();
			}
			catch(Exception e)
			{
				//no interface available, use command-line options!
				throw new NoGuiAvailableException(e);
			}
		}
Пример #7
0
		public override IRenderedInstance PreRender(UimlDocument uimlDoc)
		{
			try
			{	
				m_topWindow = new CompactSWFRenderedInstance();		
				m_topWindow.Title = uimlDoc.Title;
				Structure uiStruct   = (Structure)uimlDoc.UInterface.UStructure[0];
				Style     uiStyle    = (Style)uimlDoc.UInterface.UStyle[0];
				Behavior  uiBehavior = null;
				try{
					uiBehavior = (Behavior)uimlDoc.UInterface.UBehavior[0];
				}catch(Exception e){ /* no behavior specified */ }

				Top = uiStruct.Top;
				Voc = uimlDoc.SearchPeers(NAME).GetVocabulary();
				Control c = Render(uiStruct.Top, uiStyle);
				//Render has filled the part-tree with the concrete object references
				//to the individual widgets, now attach the behavior			
				//CompactSWFEventLinker sel = new CompactSWFEventLinker(this);
                EventLinker sel = new EventLinker(this);
				sel.Link(uiStruct, uiBehavior);
				m_topWindow.Add(c);
				return m_topWindow;
			}
			catch(NullReferenceException nrfe)
			{
				Console.WriteLine("The Rendering Engine says: Check the input documents, they seem to be invalid");
				throw nrfe;
			}
			
			catch(Exception e)
			{
				Console.WriteLine("Unexpected failure ({0}) while processing {1}:", e.GetType(), uimlDoc);
				Console.WriteLine(e.ToString());
				Console.WriteLine("Please contact the uiml.net maintainer with the above output.");
				throw e;
			}
		}
Пример #8
0
		public void Reset()
		{
			workingDoc = (UimlDocument)topDoc.Clone();		
		}
Пример #9
0
		public UimlContainerDocument(UimlDocument doc)
		{
			topDoc = doc;
			//TODO: workingDoc = (UimlDocument)topDoc.Clone();
			workingDoc = topDoc;
		}
Пример #10
0
		public RenderedInstance PreRender(UimlDocument uimlDoc)			
		{
			m_topWindow = new QtRenderedInstance();
		}
Пример #11
0
		virtual public IRenderedInstance Render(UimlDocument uimlDoc) { return PreRender(uimlDoc); }
Пример #12
0
		abstract public IRenderedInstance PreRender(UimlDocument uimlDoc);
Пример #13
0
		public override IRenderedInstance Render(UimlDocument uimlDoc)
		{
			IRenderedInstance instance = PreRender(uimlDoc);
			uimlDoc.SolveLayoutProperties(this);
			
			// of course only if there's a layout specified
			if (uimlDoc.HasLayout) 
			{
                // render again
                instance = PreRender(uimlDoc);
			
				// now do reordering
				Structure uiStruct   = (Structure)uimlDoc.UInterface.UStructure[0];
				Console.Write("Trying to reorder the interface... ");
				SWFReorderer reorderer = new SWFReorderer(uiStruct.Top);
				reorderer.Execute();
				Console.WriteLine("Done!");

				// we need to render any possible added widgets
				instance = PreRender(uimlDoc);
				
				// then the constraints must be solved
				uimlDoc.SolveLayoutProperties(this);

				// and we must render once again to apply these
				instance = PreRender(uimlDoc);
			}
			
			return instance;
		}
Пример #14
0
        private void Render(string file)
        {
			try
			{
                UimlDoc = new UimlDocument(file);	
				Console.WriteLine("render [" + uimlDoc.Vocabulary + "]-[" + file + "]");
				IRenderer renderer =  (new BackendFactory()).CreateRenderer(uimlDoc.Vocabulary);	
				IRenderedInstance instance = renderer.Render(uimlDoc);
                // connect the frontend to the document, to allow communication at runtime
                UimlDoc.Connect(this);
                // connect the rendered instance to the document
                UimlDoc.Instance = instance;
                // add to the list
                renderedUIs.Add(FileToDictionaryKey(file), instance);
                // connect close event
                instance.CloseWindow += new EventHandler(UimlDocument_Closed);
                // connect activate event
                instance.ActivateWindow += new EventHandler(UimlDocument_Activated);
                instance.ShowIt();
			}
			catch (NoRendererAvailableException rue)
			{
				Console.WriteLine("No suitable renderer found:");
				Console.WriteLine("  Please check if the rendering backend corresponding to the vocabulary is available");
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
#if !COMPACT
				Console.WriteLine(e.StackTrace);				
#endif
				Console.WriteLine("Could not create GUI for {0} with uiml.net", UimlFileName);
			}
		}
Пример #15
0
		public UimlComposite(UimlDocument acontainer)
		{
			container = new UimlContainerDocument(acontainer);
			leaves = new Hashtable();
		}