OnWidgetNameChanged() private method

private OnWidgetNameChanged ( Stetic args, bool isTopLevel ) : void
args Stetic
isTopLevel bool
return void
        public void CopyWidgetToProject(string name, ProjectBackend other, string replacedName)
        {
            WidgetData wdata = GetWidgetData(name);

            if (name == null)
            {
                throw new InvalidOperationException("Component not found: " + name);
            }

            XmlElement data;

            if (wdata.Widget != null)
            {
                data = Stetic.WidgetUtils.ExportWidget(wdata.Widget);
            }
            else
            {
                data = (XmlElement)wdata.XmlData.Clone();
            }

            // If widget already exist, replace it
            wdata = other.GetWidgetData(replacedName);
            if (wdata == null)
            {
                wdata = new WidgetData(name, data, null);
                other.topLevels.Add(wdata);
            }
            else
            {
                if (wdata.Widget != null)
                {
                    // If a widget instance already exist, load the new data on it
                    Wrapper.Widget sw = Wrapper.Widget.Lookup(wdata.Widget);
                    sw.Read(new ObjectReader(other, FileFormat.Native), data);
                    sw.NotifyChanged();
                    if (name != replacedName)
                    {
                        other.OnWidgetNameChanged(new Wrapper.WidgetNameChangedArgs(sw, replacedName, name), true);
                    }
                }
                else
                {
                    wdata.SetXmlData(name, data);
                    if (name != replacedName)
                    {
                        other.OnWidgetNameChanged(new Wrapper.WidgetNameChangedArgs(null, replacedName, name), true);
                    }
                }
            }
        }
Beispiel #2
0
		public void CopyWidgetToProject (string name, ProjectBackend other, string replacedName)
		{
			WidgetData wdata = GetWidgetData (name);
			if (name == null)
				throw new InvalidOperationException ("Component not found: " + name);
			
			XmlElement data;
			if (wdata.Widget != null)
				data = Stetic.WidgetUtils.ExportWidget (wdata.Widget);
			else
				data = (XmlElement) wdata.XmlData.Clone ();
			
			// If widget already exist, replace it
			wdata = other.GetWidgetData (replacedName);
			if (wdata == null) {
				wdata = new WidgetData (name, data, null);
				other.topLevels.Add (wdata);
			} else {
				if (wdata.Widget != null) {
					// If a widget instance already exist, load the new data on it
					Wrapper.Widget sw = Wrapper.Widget.Lookup (wdata.Widget);
					sw.Read (new ObjectReader (other, FileFormat.Native), data);
					sw.NotifyChanged ();
					if (name != replacedName)
						other.OnWidgetNameChanged (new Wrapper.WidgetNameChangedArgs (sw, replacedName, name), true);
				} else {
					wdata.SetXmlData (name, data);
					if (name != replacedName)
						other.OnWidgetNameChanged (new Wrapper.WidgetNameChangedArgs (null, replacedName, name), true);
				}
			}
		}