/// <summary> /// Selects the workflow with the specified name from the default workflow menu. /// </summary> /// <param name="workflowName">The workflow name.</param> public void SelectWorkflow(string workflowName) { Widget groupWidget = _controlPanel.GetWidgets().Find("1.", StringMatch.StartsWith); _controlPanel.Press(groupWidget); // Wait for the workflows to load, then let it settle for a moment Wait.ForNotNull(() => _controlPanel.GetWidgets().Find("Workflow >", StringMatch.StartsWith), TimeSpan.FromSeconds(20)); Thread.Sleep(TimeSpan.FromSeconds(2)); Pacekeeper.Sync(); // Find the workflow and select it WidgetCollection workflowWidgets = _controlPanel.GetWidgets().OfType(WidgetType.HelpListItem); string workflowMatch = StringMatcher.FindBestMatch(workflowName, workflowWidgets.Select(n => n.Text), StringMatch.Contains, ignoreCase: true); if (workflowMatch != null) { Widget workflow = _controlPanel.ScrollToItem("StringContent1", workflowMatch); _controlPanel.Press(workflow); } else { throw new DeviceWorkflowException($"Could not find workflow named '{workflowName}'."); } // Wait for the parameters to load, then let it settle for a moment _controlPanel.WaitForScreen(_workflowMain, TimeSpan.FromSeconds(20)); Thread.Sleep(TimeSpan.FromSeconds(2)); Pacekeeper.Sync(); }
private bool AreLocationsIncorrect() { WidgetCollection editBoxes = _controlPanel.GetWidgets().OfType(WidgetType.EditBox); int distinctLocations = editBoxes.Select(n => n.Location).Distinct().Count(); return(distinctLocations < editBoxes.Count); }
private void PressPrompt(WidgetCollection widgets, Widget label) { if (ArePromptLocationsCorrect(widgets)) { Widget promptBox = widgets.FindByLabel(label, WidgetType.Button); _controlPanel.Press(promptBox); } else { if (AreTextBoxLocationsCorrect(widgets)) { // For some devices, the workflow parameters screen reports the same bounding box for each label, which // makes it impossible to determine which label corresponds to which text box by comparing their position. // Instead, we are forced to make an assumption based on the way the controls are dynamically created: // each text box corresponds to the prompt with an ID exactly 1 greater than the box's ID. _controlPanel.Press(label.Id - 1); } else { // On the workflow parameters screen, the bounding boxes are the same for all the labels AND text boxes. // We'll need to make some assumptions about the way the controls are dynamically created: // Each text box corresponds to the prompt with an ID exactly 1 greater than the box's ID, // AND the text box IDs are in ascending order as we move down the screen. int textBoxId = label.Id - 1; // Calculate the y offset from the top box's press coordinate. // There are 50 pixels between each edit box and the ID increments by 2 for each box. // The top box always has ID 1500 Widget topBox = widgets.Find(1500); var topBoxCenter = new Coordinate(topBox.Location.X + topBox.Size.Width / 2, topBox.Location.Y + topBox.Size.Height / 2); int offset = (textBoxId - topBox.Id) / 2 * 50; _controlPanel.PressScreen(new Coordinate(topBoxCenter.X, topBoxCenter.Y + offset)); } } }
/// <summary> /// Enters the specified value for the specified workflow prompt. /// </summary> /// <param name="prompt">The prompt.</param> /// <param name="value">The value.</param> public void EnterPromptValue(string prompt, string value) { WidgetCollection widgets = _controlPanel.GetWidgets(); IEnumerable <string> prompts = widgets.OfType(WidgetType.Prompt).Select(n => n.Text); // Find the text box for the prompt and press it to navigate to the keyboard screen string promptMatch = StringMatcher.FindBestMatch(prompt, prompts, StringMatch.Contains, ignoreCase: true, ignoreWhiteSpace: true); if (promptMatch != null) { Widget label = widgets.Find(promptMatch); PressPrompt(widgets, label); _controlPanel.WaitForScreen(_workflowKeyboard, TimeSpan.FromSeconds(5)); Pacekeeper.Sync(); // Enter the parameter text, then navigate back to the parameter screen _controlPanel.TypeOnVirtualKeyboard(value); Pacekeeper.Sync(); _controlPanel.Press("OK"); _controlPanel.WaitForScreen(_workflowMain, TimeSpan.FromSeconds(5)); Pacekeeper.Sync(); } else { throw new DeviceWorkflowException($"Could not find workflow prompt '{prompt}'."); } }
private static bool ArePromptLocationsCorrect(WidgetCollection widgets) { WidgetCollection prompts = widgets.OfType(WidgetType.Prompt); int distinctLocations = prompts.Select(n => n.Location).Distinct().Count(); return(distinctLocations == prompts.Count); }
private static bool AreTextBoxLocationsCorrect(WidgetCollection widgets) { WidgetCollection textBoxes = widgets.OfType(WidgetType.EditBox); int distinctLocations = textBoxes.Select(n => n.Location).Distinct().Count(); return(distinctLocations == textBoxes.Count); }
public void Split(string fieldName, string captionName, params string[] args) { Widget dataset = new Widget(); WidgetCollection rows = this["rows"] as WidgetCollection; if (rows == null || rows.Count < 1) { return; } Widget prevRow = rows[0]; object prevValue = prevRow[fieldName]; WidgetCollection temp = new WidgetCollection(); foreach (Widget i in rows) { object v = i[fieldName]; if (!object.Equals(v, prevValue)) { AddPreviousCategory(captionName, dataset, prevRow, temp, args); temp = new WidgetCollection(); prevRow = i; prevValue = v; } temp.Add(i); } AddPreviousCategory(captionName, dataset, prevRow, temp, args); this["dataset"] = dataset; this.Remove("rows"); }
protected GridWidget() { this["defaultEditor"] = "editbox"; this["defaultStyle"] = null; this["styles"] = null; this["cols"] = new WidgetCollection(); this["rows"] = new WidgetCollection(); }
public void OnActionExecuted(ActionExecutedContext filterContext) { Zones = new ZoneWidgetCollection(); //Page var page = GetPage(filterContext); if (page != null) { var cache = new StaticCache(); var layoutService = ServiceLocator.Current.GetInstance <ILayoutService>(); LayoutEntity layout = layoutService.Get(page.LayoutId); layout.Page = page; Action <WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source => Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver ); WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (Zones) { if (Zones.ContainsKey(part.Widget.ZoneID)) { Zones[part.Widget.ZoneID].Add(part); } else { var partCollection = new WidgetCollection { part }; Zones.Add(part.Widget.ZoneID, partCollection); } } }; var widgetService = ServiceLocator.Current.GetInstance <IWidgetService>(); IEnumerable <WidgetBase> widgets = widgetService.GetAllByPageId(page.ID); var parallel = from widget in widgets.AsParallel() select widget; parallel.ForAll(processWidget); layout.ZoneWidgets = Zones; var viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { string layoutView = GetLayout(); if (layoutView.IsNotNullAndWhiteSpace()) { viewResult.MasterName = layoutView; } viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
public void OnActionExecuted(ActionExecutedContext filterContext) { ZoneWidgetCollection zones = new ZoneWidgetCollection(); //Page string pageId = filterContext.RequestContext.HttpContext.Request.QueryString["ID"]; PageService pageService = new PageService(); PageEntity page = pageService.Get(pageId); if (page != null) { LayoutService layoutService = new LayoutService(); var layout = layoutService.Get(page.LayoutId); layout.Page = page; WidgetService widgetService = new WidgetService(); IEnumerable <WidgetBase> widgets = widgetService.Get(new DataFilter().Where <WidgetBase>(m => m.PageID, OperatorType.Equal, page.ID)); Action <WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver; WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (zones) { if (zones.ContainsKey(part.Widget.ZoneID)) { zones[part.Widget.ZoneID].Add(part); } else { WidgetCollection partCollection = new WidgetCollection(); partCollection.Add(part); zones.Add(part.Widget.ZoneID, partCollection); } } }; widgets.Each(processWidget); IEnumerable <WidgetBase> Layoutwidgets = widgetService.Get(new Data.DataFilter().Where <WidgetBase>(m => m.LayoutID, OperatorType.Equal, page.LayoutId)); Layoutwidgets.Each(processWidget); layout.ZoneWidgets = zones; ViewResult viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { viewResult.MasterName = "~/Modules/Common/Views/Shared/_DesignPageLayout.cshtml"; viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
public void OnActionExecuted(ActionExecutedContext filterContext) { ZoneWidgetCollection zones = new ZoneWidgetCollection(); //Page string pageId = filterContext.RequestContext.HttpContext.Request.QueryString["ID"]; PageService pageService = new PageService(); PageEntity page = pageService.Get(pageId); if (page != null) { LayoutService layoutService = new LayoutService(); var layout = layoutService.Get(page.LayoutId); layout.Page = page; WidgetService widgetService = new WidgetService(); IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where<WidgetBase>(m => m.PageID, OperatorType.Equal, page.ID)); Action<WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver; WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (zones) { if (zones.ContainsKey(part.Widget.ZoneID)) { zones[part.Widget.ZoneID].Add(part); } else { WidgetCollection partCollection = new WidgetCollection(); partCollection.Add(part); zones.Add(part.Widget.ZoneID, partCollection); } } }; widgets.Each(processWidget); IEnumerable<WidgetBase> Layoutwidgets = widgetService.Get(new Data.DataFilter().Where<WidgetBase>(m => m.LayoutID, OperatorType.Equal, page.LayoutId)); Layoutwidgets.Each(processWidget); layout.ZoneWidgets = zones; ViewResult viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { viewResult.MasterName = "~/Modules/Common/Views/Shared/_DesignPageLayout.cshtml"; viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
/// <summary> /// 创建部件配置 /// </summary> /// <param name="dcs"></param> /// <returns></returns> private void CreateWidgetConfig(List <DataControlInfo> dcs, string filePath) { WidgetCollection wdCollection = new WidgetCollection(); wdCollection.Name = "default"; wdCollection.Label = "部件列表信息"; wdCollection.Description = "部件列表信息"; Dictionary <string, WidgetGroup> groups = new Dictionary <string, WidgetGroup>(); foreach (DataControlInfo dci in dcs) { if (dci.Controls.Count == 0) { continue; } WidgetGroup group; if (!groups.ContainsKey(dci.Group)) { group = new WidgetGroup(); group.Description = dci.Group; group.Label = dci.Group; group.Name = dci.Group; groups.Add(dci.Group, group); wdCollection.Groups.Add(group); } else { group = groups[dci.Group]; } Widget wd = new Widget(); wd.Name = dci.Name; wd.Label = dci.GroupLabel; wd.Icon = dci.GroupIcon; wd.File = dci.Path; wd.Description = dci.GroupDesc; wd.DefaultType = dci.GroupDefaultType; foreach (DataControl dc in dci.Controls) { WidgetType wdType = new WidgetType(); wdType.Name = dc.Name; wdType.File = dc.FileName; wdType.Label = dc.Description; wdType.Control = dc.Name.Replace(".", "_"); wd.Types.Add(wdType); } group.Widgets.Add(wd); } SerializationHelper.Save(wdCollection, filePath); }
/// <summary> /// Find the element in widget /// </summary> /// <param name="device"></param> /// <param name="widgetId"></param> /// <returns></returns> private static Widget WidgetFind(SiriusUIv2Device device, string widgetId) { WidgetCollection wc = device.ControlPanel.GetScreenInfo().Widgets; try { return(wc.First(n => StringMatcher.IsMatch(widgetId, n.Id, StringMatch.Exact, true))); } catch { return(null); } }
/// <summary> /// Find the element in widget /// </summary> /// <param name="widgetId"></param> /// <returns></returns> protected Widget FindWidget(string widgetId) { WidgetCollection wc = ControlPanel.GetScreenInfo().Widgets; try { return(wc.First(n => StringMatcher.IsMatch(widgetId, n.Id, StringMatch.Exact, true))); } catch { return(null); } }
/// <summary> /// Applies the Provider to the authentication method on the device. /// </summary> /// <param name="provider"></param> protected virtual void SetDeviceProvider(AuthenticationProvider provider) { WidgetCollection widgets = ControlPanel.GetScreenInfo().Widgets; Widget widget = widgets.FirstOrDefault(w => w.Values.Keys.Contains("text") && w.Values["text"] == ProviderMap[provider].DisplayText); if (widget != null) { // The item exists, select the value ControlPanel.PerformAction(WidgetAction.Select, widget.Id); } else { throw new DeviceInvalidOperationException($"Unable to set SignIn method to {EnumUtil.GetDescription(provider)}."); } }
/// <summary> /// Selects the folder quickset with the specified name. /// </summary> /// <param name="quicksetName">The quickset name.</param> public void SelectQuickset(string quicksetName) { WidgetCollection quicksetWidgets = _controlPanel.GetWidgets().OfType(WidgetType.HelpListItem); string bestMatch = StringMatcher.FindBestMatch(quicksetName, quicksetWidgets.Select(n => n.Text), StringMatch.StartsWith, ignoreCase: true, ignoreWhiteSpace: true, allowPartialMatch: true); if (bestMatch != null) { Widget quickset = _controlPanel.ScrollToItem("StringContent1", bestMatch); _controlPanel.Press(quickset); Pacekeeper.Sync(); } else { throw new DeviceWorkflowException($"Could not find the quickset '{quicksetName}'."); } }
/// <summary> /// This is a debugging tool to help determine what is showing on the screen /// </summary> protected void DumpScreen() { WidgetCollection wc = ControlPanel.GetScreenInfo().Widgets; StringBuilder output = new StringBuilder(); foreach (Widget w in wc) { output.Clear(); output.Append(w.Id).Append(": ").AppendLine(w.WidgetType.ToString()); foreach (string key in w.Values.Keys) { output.Append("\t"); output.AppendLine(w.Values[key]); } System.Diagnostics.Debug.WriteLine(output.ToString()); } }
static void Main(string[] args) { var server = MongoServer.Create(); server.Connect(); var db = server.GetDatabase("widgettest"); var collection = db.GetCollection <WidgetCollection>("widgets"); collection.Drop(); var widgets = new WidgetCollection(); var widget1 = new Widget { Title = "One", Position = 0, IsActive = true }; var widget2 = new Widget { Title = "Two", Position = 1, IsActive = true }; var widget3 = new Widget { Title = "Three", Position = 2, IsActive = false }; widgets.Widgets = new List <Widget> { widget1, widget2, widget3 }.AsReadOnly(); collection.Save(widgets); var command = new CommandDocument( new BsonElement("aggregate", "widgets"), new BsonElement("pipeline", new BsonArray(new [] { new BsonDocument( new BsonElement("$project", new BsonDocument("Widgets", 1))) }))); var response = db.RunCommand(command); var rawDoc = response.Response["result"].AsBsonArray.SingleOrDefault().AsBsonDocument; var doc = BsonSerializer.Deserialize <WidgetCollection>(rawDoc); //Console.ReadKey(); }
/// <summary> /// Enables email notification for this job. /// </summary> /// <param name="condition">The condition under which to send notification.</param> /// <param name="address">The email address to receive the notification.</param> /// <param name="thumbNail">if set to<c>true>enable thumbnail;otherwise,disable it</c></param>//We have added thumbnail parameter but not yet implemented it public void EnableEmailNotification(NotifyCondition condition, string address, bool thumbNail) { Widget serviceButton = ScrollToOption("Notification"); Pacekeeper.Sync(); _controlPanel.Press(serviceButton); Pacekeeper.Sync(); // Press the notify option, then wait for the other widgets to load string notifyOption = (condition == NotifyCondition.OnlyIfJobFails ? "On error" : "This job"); _controlPanel.Press(notifyOption); Thread.Sleep(TimeSpan.FromSeconds(1)); Pacekeeper.Sync(); // On some devices (digital senders) this widget doesn't exist, since only email is available WidgetCollection widgets = _controlPanel.GetWidgets(); Widget emailWidget = widgets.Find("E-mail"); if (emailWidget != null) { _controlPanel.Press(emailWidget); Pacekeeper.Sync(); } // Enter the email address Widget label = widgets.Find("E-mail Address", StringMatch.StartsWith); Widget emailStringBox = widgets.FindByLabel(label, WidgetType.StringBox); _controlPanel.Press(emailStringBox); Pacekeeper.Sync(); _controlPanel.PressKey(OzHardKey.Clear); _controlPanel.TypeOnVirtualKeyboard(address); Pacekeeper.Sync(); _controlPanel.Press("OK"); Thread.Sleep(TimeSpan.FromSeconds(1)); Pacekeeper.Sync(); _controlPanel.Press("OK"); Pacekeeper.Sync(); }
/// <summary> /// 获取系统widgets /// </summary> /// <returns></returns> public WidgetCollection GetSystemWidgetList() { var widgets = new WidgetCollection(); try { //检查WidgetIndex.xml是否存在 if (!File.Exists(WidgetConfigPath)) { BaseControlHelper Helper = new BaseControlHelper(); Helper.CreateWidegetsIndex(); } widgets = SerializationHelper.Load <WidgetCollection>(WidgetConfigPath); } catch (Exception ex) { throw new Exception(ex.Message); } return(widgets); }
/// <summary> /// 测试序列化生成 /// </summary> /// <param name="file"></param> public static void CreateTestConfigFile(string file) { WidgetCollection wdCollection = new WidgetCollection(); wdCollection.Name = "Test"; wdCollection.Label = "测试"; wdCollection.Description = "描述"; for (int i = 0; i < 4; i++) { WidgetGroup wdGroup = new WidgetGroup(); wdGroup.Name = "group" + i.ToString(); wdGroup.Label = "组" + i.ToString(); wdGroup.Description = "描述" + i.ToString(); for (int j = 0; j < 5; j++) { Widget wd = new Widget(); wd.Name = "Name" + j.ToString(); wd.Label = "Label" + j.ToString(); wd.Icon = "ICOn" + j.ToString(); wd.File = "File" + j.ToString(); wd.DefaultType = "Name1"; wd.Description = "description1"; for (int k = 0; k < 3; k++) { WidgetType wdType = new WidgetType(); wdType.Name = "Name" + k.ToString(); wdType.Label = "Label" + k.ToString(); wd.Types.Add(wdType); } wdGroup.Widgets.Add(wd); } wdCollection.Groups.Add(wdGroup); SerializationHelper.Save(wdCollection, file); } }
/// <summary> /// Gets the current control ids. /// </summary> public override void GetCurrentControlIds() { WidgetCollection wc = _controlPanel.GetScreenInfo().Widgets; ControlPanelControlIds = string.Join(",", wc.Select(x => x.Id).ToArray()); }
private void PopulateTreeWithWidgets(WidgetCollection widgets) { foreach (Widget widget in widgets) { Gdk.Pixbuf image = GetImage(widget.Type); if (typeIters[widget.Type] == null) { string name = widget.Type; //.Substring(3); if (name.EndsWith("x")) name += "es"; else if (name.EndsWith("y")) name = name.Substring(0, name.Length -1) + "ies"; else name += "s"; Gtk.TreeIter newIter = widgetTreeStore.AppendValues(currentWindowIter, image, name, true, null); typeIters.Add(widget.Type, newIter); } Gtk.TreeIter parentIter = (Gtk.TreeIter)typeIters[widget.Type]; widgetTreeStore.AppendValues(parentIter, null, widget.Name, false, widget); PopulateTreeWithWidgets(widget.Widgets); } }
private static void AddPreviousCategory(string captionName, Widget dataset, Widget prevRow, WidgetCollection temp, params string [] args) { Widget data = dataset.Use<Widget>(Convert.ToString(prevRow[captionName])); foreach (string i in args) { string[] item = i.Split('='); if (item.Length == 1 && prevRow.ContainsKey(item[0])) { data[i] = prevRow[item[0]]; } else if (item.Length > 1) { string key = item[0]; item[0] = string.Empty; data[key] = string.Join("=", item).Substring(1); } } data["rows"] = temp; }
public void OnActionExecuted(ActionExecutedContext filterContext) { var zones = new ZoneWidgetCollection(); var cache = new StaticCache(); //Page string path = filterContext.RequestContext.HttpContext.Request.Path; if (path.EndsWith("/") && path.Length > 1) { path = path.Substring(0, path.Length - 1); //filterContext.HttpContext.Response.Redirect(path); filterContext.Result = new RedirectResult(path); return; } bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase); var page = new PageService().GetByPath(path, publish); if (page != null) { var layoutService = new LayoutService(); LayoutEntity layout = layoutService.Get(page.LayoutId); layout.Page = page; Action <WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source => Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver ); WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (zones) { if (zones.ContainsKey(part.Widget.ZoneID)) { zones[part.Widget.ZoneID].Add(part); } else { var partCollection = new WidgetCollection { part }; zones.Add(part.Widget.ZoneID, partCollection); } } }; var layoutWidgetsTask = Task.Factory.StartNew(layoutId => { var widgetServiceIn = new WidgetService(); IEnumerable <WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId)); layoutwidgets.Each(processWidget); }, page.LayoutId); var widgetService = new WidgetService(); IEnumerable <WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID)); int middle = widgets.Count() / 2; var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget)); widgets.Take(middle).Each(processWidget); Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask }); layout.ZoneWidgets = zones; var viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml"; viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
public void OnActionExecuted(ActionExecutedContext filterContext) { var zones = new ZoneWidgetCollection(); var cache = new StaticCache(); //Page string path = filterContext.RequestContext.HttpContext.Request.Path; if (path.EndsWith("/") && path.Length > 1) { path = path.Substring(0, path.Length - 1); //filterContext.HttpContext.Response.Redirect(path); filterContext.Result = new RedirectResult(path); return; } bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase); var page = new PageService().GetByPath(path, publish); if (page != null) { var layoutService = new LayoutService(); LayoutEntity layout = layoutService.Get(page.LayoutId); layout.Page = page; Action<WidgetBase> processWidget = m => { IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source => Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver ); WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext); lock (zones) { if (zones.ContainsKey(part.Widget.ZoneID)) { zones[part.Widget.ZoneID].Add(part); } else { var partCollection = new WidgetCollection { part }; zones.Add(part.Widget.ZoneID, partCollection); } } }; var layoutWidgetsTask = Task.Factory.StartNew(layoutId => { var widgetServiceIn = new WidgetService(); IEnumerable<WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId)); layoutwidgets.Each(processWidget); }, page.LayoutId); var widgetService = new WidgetService(); IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID)); int middle = widgets.Count() / 2; var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget)); widgets.Take(middle).Each(processWidget); Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask }); layout.ZoneWidgets = zones; var viewResult = (filterContext.Result as ViewResult); if (viewResult != null) { //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml"; viewResult.ViewData[LayoutEntity.LayoutKey] = layout; } } else { filterContext.Result = new HttpStatusCodeResult(404); } }
public int CountSelectedWidgets(WidgetCollection startAt) { int count = 0; foreach (Widget toplevel in startAt) { if (toplevel.GenerateCode) { count++; foreach (Widget widget in toplevel.Widgets) { if (widget.GenerateCode) count ++; } } } return count; }
private void PopulateTreeWithWindows(WidgetCollection windows) { foreach (Widget widget in windows) { if (widget.Type == "GtkWindow" | widget.Type == "GtkMenu" | widget.Type == "GnomeApp" | widget.Type.EndsWith("Dialog")) { Gdk.Pixbuf image = GetImage(widget.Type); currentWindowIter = widgetTreeStore.AppendValues(image, widget.Name, true, widget); } } }