public virtual void NavigateTo(ViewType view, object parm = null) { if (parm == null) { _navigationService.NavigateTo(view.ToString()); } else { _navigationService.NavigateTo(view.ToString(), parm); } }
private XmlNode _makeTreeViewXmlNode(XmlDocument XmlDoc, string ID, ViewType Type, string Text, string ImageUrl, bool Selectable, bool Searchable) //, string ClientSideCommand) { XmlNode Node = XmlDoc.CreateElement("Node"); XmlAttribute IDAttribute = XmlDoc.CreateAttribute("ID"); IDAttribute.Value = Type.ToString() + "_" + ID; Node.Attributes.Append(IDAttribute); XmlAttribute ValueAttribute = XmlDoc.CreateAttribute("Value"); ValueAttribute.Value = Type.ToString() + "_" + ID; Node.Attributes.Append(ValueAttribute); XmlAttribute TextAttribute = XmlDoc.CreateAttribute("Text"); TextAttribute.Value = Text; Node.Attributes.Append(TextAttribute); XmlAttribute ImageUrlAttribute = XmlDoc.CreateAttribute("ImageUrl"); ImageUrlAttribute.Value = ImageUrl; Node.Attributes.Append(ImageUrlAttribute); XmlAttribute PostBackAttribute = XmlDoc.CreateAttribute("PostBack"); PostBackAttribute.Value = Selectable.ToString().ToLower(); Node.Attributes.Append(PostBackAttribute); XmlAttribute CssClassAttribute = XmlDoc.CreateAttribute("CssClass"); CssClassAttribute.Value = "TreeNode"; Node.Attributes.Append(CssClassAttribute); XmlAttribute HoveredCssClassAttribute = XmlDoc.CreateAttribute("HoveredCssClass"); HoveredCssClassAttribute.Value = "HoverTreeNode"; Node.Attributes.Append(HoveredCssClassAttribute); XmlAttribute SelectedCssClassAttribute = XmlDoc.CreateAttribute("SelectedCssClass"); SelectedCssClassAttribute.Value = "SelectedTreeNode"; Node.Attributes.Append(SelectedCssClassAttribute); XmlAttribute SearchableAttribute = XmlDoc.CreateAttribute("Searchable"); SearchableAttribute.Value = Searchable.ToString().ToLower(); Node.Attributes.Append(SearchableAttribute); //if (ClientSideCommand != string.Empty) //{ // XmlAttribute ClientSideCommandAttribute = XmlDoc.CreateAttribute("OnClientNodeClicking"); // ClientSideCommandAttribute.Value = ClientSideCommand; // Node.Attributes.Append(ClientSideCommandAttribute); //} return(Node); }
protected dynamic GetViewJson(ViewType type) { var json = ReadViewJson(type, strict: false); if (json != null) { return(new Response { StatusCode = HttpStatusCode.OK, ContentType = MediaType.Json.ToString(), Contents = body => { using (var writer = new StreamWriter(body)) { writer.Write(json); } } }); } return(new Response { StatusCode = HttpStatusCode.NotFound, ReasonPhrase = "Failed to read " + type.ToString() }); }
public static string MakeLetterLink(string board_id, string discussion_id, string letter_id, ViewType view_type) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("/{0}/{1}", board_id, discussion_id); if (view_type != ViewType.horizontal) { builder.Append("?view=" + view_type.ToString()); } if (letter_id != SandId.HEADING_LETTER_ID) { builder.Append('#'); //if (view_is_map) if (view_type != ViewType.horizontal) { builder.Append("g_"); } builder.Append(letter_id); } return(builder.ToString()); //return string.Format("/{0}/{1}{2}#{3}", board_id, discussion_id, view_is_map ? "?view=map" : string.Empty, letter_id); }
public override string SaveExtraText() { return(Helper.SaveDictionaryToString(new Dictionary <string, string>() { { "ViewType", ViewType.ToString() } })); }
public async Task <ListExperimentsResponse> ListExperiments(ViewType viewtype) { var response = await _httpService.Get <ListExperimentsResponse, Object>( _getPath(MLFlowAPI.Experiments.BasePath, MLFlowAPI.Experiments.List), new { viewtype = viewtype.ToString() }); return(response); }
public override void Execute() { var viewType = (AnalysisViewType)Enum.Parse(typeof(AnalysisViewType), ViewType.ToString()); switch (viewType) { case AnalysisViewType.Idle: View = new AnalysisWindow(this); View.ShowDialog(); break; case AnalysisViewType.Close: View.Close(); break; case AnalysisViewType.DisplayGeometry: View.Close(); if (!VLHookHelper.DelegateKeyBoardHook(() => { Model.TargetId = UIDocument.Selection.PickObject(ObjectType.Element, "请选择对象").ElementId; })) { Model.TargetId = null; ViewType = (int)AnalysisViewType.Idle; } if (VLTransactionHelper.DelegateTransaction(Document, "DisplayGeometry", () => { if (Model.TargetId == null) { return(false); } if (string.IsNullOrEmpty(RootPath)) { MessageHelper.TaskDialogShow("根路径不能为空"); return(false); } Model.Document = Document; Model.RootPath = RootPath; Model.DisplayName = ViewType.ToString(); Model.DisplayGeometry(); AnalysisContext.SaveCollection(Document); return(true); })) { ViewType = (int)AnalysisViewType.DisplayGeometry; } else { ViewType = (int)AnalysisViewType.Idle; } Execute(); break; default: throw new NotImplementedException("功能未实现"); } }
private void GetSelectedViews() { this.m_selectViewsData.Contain3DView = false; checked { foreach (int index in this.checkedListBoxViews.CheckedIndices) { string text = this.checkedListBoxViews.Items[index].ToString(); string text2 = "Drawing Sheet: "; if (text.StartsWith(text2)) { text = text.Substring(text2.Length); string b = text.Substring(0, text.IndexOf(" - ")); string b2 = text.Substring(text.IndexOf(" - ") + 3); IEnumerator enumerator2 = this.m_selectViewsData.PrintableSheets.GetEnumerator(); try { while (enumerator2.MoveNext()) { ViewSheet viewSheet = (ViewSheet)enumerator2.Current; if (viewSheet.SheetNumber == b && viewSheet.ViewName == b2) { this.m_selectViewsData.SelectedViews.Insert(viewSheet); break; } } continue; } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } string a = text.Substring(0, text.IndexOf(": ")); string a2 = text.Substring(text.IndexOf(": ") + 2); foreach (Autodesk.Revit.DB.View view in this.m_selectViewsData.PrintableViews) { ViewType viewType = view.ViewType; if (a == viewType.ToString() && a2 == view.ViewName) { this.m_selectViewsData.SelectedViews.Insert(view); if (viewType == ViewType.ThreeD) { this.m_selectViewsData.Contain3DView = true; break; } break; } } } } }
private void CreateButton(ViewType type, bool on = true) { int size = this.flowLayoutPanel1.Height; StatusImageButton button = new StatusImageButton(); this.flowLayoutPanel1.Controls.Add(button); button.Image = type.Bitmap(); button.Location = new System.Drawing.Point(0, 0); button.Name = type.ToString(); button.Tag = type; button.OffImageType = Sardauscan.Gui.Controls.eOffButtonType.NotSelected; button.On = on; button.Size = new System.Drawing.Size(size, size); button.Click += OnButtonClick; button.Margin = new Padding(0); this.ToolTip.SetToolTip(button, type.ToString()); flowLayoutPanel1.Width = size * flowLayoutPanel1.Controls.Count; flowLayoutPanel1.Height = size; }
protected virtual string BuildViewTypeName(Type viewModelType, ViewType viewType) { if (viewModelType == null) { throw new ArgumentNullException(nameof(viewModelType)); } return(viewModelType.FullName? .Replace(".ViewModels.", ".Droid.Views.") .Replace("ViewModel", viewType.ToString()) ?? string.Empty); }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(false); } ViewType myViewType = ViewType.默认; Enum.TryParse <ViewType>(value.ToString(), out myViewType); return(myViewType.ToString() == parameter.ToString()); }
protected dynamic GetView(ViewType type) { var view = ReadView(type, strict: false); if (view != null) { return(view); } return(new Response { StatusCode = HttpStatusCode.NotFound, ReasonPhrase = "Failed to read " + type.ToString() }); }
private void SetLastViewAccessByUser(ViewType viewType) { var repository = new MongoRepository <UserPreference>(); var user = repository.SingleOrDefault(u => u.UserIdentity == User.Identity.Name); if (user == null) { user = new UserPreference(); user.Id = Guid.NewGuid().ToString(); user.UserIdentity = User.Identity.Name; } user.HomeViewSelected = viewType.ToString(); repository.Update(user); }
public static void WriteDiscussionAnchor(this TextWriter writer, string board_id, string discussion_id, string heading, ViewType view_type) { writer.Write("<a href='/"); writer.Write(board_id); writer.Write('/'); writer.Write(discussion_id); if (view_type != ViewType.horizontal) { writer.Write("?view=" + view_type.ToString()); } writer.Write("'>"); writer.Write(heading); // beware of xss attack. writer.Write("</a>"); }
/// <summary> /// print the specified ViewType. /// </summary> public void Print(ViewType viewType) { try { Autodesk.Revit.DB.View view = null; // Create a view set to contain all view of designated type ViewSet views = m_doc.Application.Create.NewViewSet(); // Create a filter to filtrate the View Element. ElementClassFilter fileterView = new ElementClassFilter(typeof(VIEW)); FilteredElementCollector collector = new FilteredElementCollector(m_doc); collector.WherePasses(fileterView); IList <Element> arrayView = collector.ToElements(); // filtrate the designated type views. foreach (Element ee in arrayView) { view = ee as VIEW; if ((null != view) && (viewType == view.ViewType) && view.IsTemplate == false) { views.Insert(view); } } // print if (!views.IsEmpty) { m_doc.Print(views); } else { MessageBox.Show("No " + viewType.ToString() + " view to be printed!", "QuickPrint"); } } catch (Exception ee) { MessageBox.Show(ee.Message); } }
/// <summary> /// change view /// </summary> /// <param name="view"></param> /// <param name="parmeters"></param> public void ChangeView(ViewType viewtype) { m_CurrentView = viewtype; if (m_RegisteredViews.ContainsKey(viewtype)) { View view = m_RegisteredViews[viewtype]; foreach (View v in m_RegisteredViews.Values) { bool vis = v.Type == view.Type; if (v.BigControl != null) { v.BigControl.Visible = vis; } if (v.SmallControl != null) { v.SmallControl.Visible = vis; } } m_BigContainer.Controls.Clear(); m_SmallContainer.Controls.Clear(); if (view.BigControl != null) { m_BigContainer.Controls.Add(view.BigControl); view.BigControl.Dock = DockStyle.Fill; view.BigControl.Visible = true; } if (view.SmallControl != null) { m_SmallContainer.Controls.Add(view.SmallControl); view.SmallControl.Dock = DockStyle.Fill; view.SmallControl.Visible = true; } } else { throw new Exception("View " + viewtype.ToString() + " is not registered"); } FireViewChanged(); }
public List <ReSourceRequest> GetListResourceRequest(ViewType type) { string[] spam = null; string where = string.Empty; switch (type.ToString()) { case "Hot": where = " order by useful,AddTime"; break; default: case "Fresh": where = " order by AddTime desc"; break; case "My": where = " where OpenId={0} order by AddTime Desc"; spam[0] = CookieHelper.GetCookieValue("OpenId"); break; } DataTable dt = dal.GetListResourceRequest(where, spam); if (dt == null || dt.Rows.Count <= 0) { return(null); } List <int> mylist = new List <int>(); foreach (DataRow dr in dt.Rows) { mylist.Add(int.Parse(dr["Id"].ToString())); } List <ReSourceRequest> list = new List <ReSourceRequest>(); foreach (int RId in mylist) { ReSourceRequest model = GenneralT <ReSourceRequest>(dal.GetSingleResourceRequest(RId)); list.Add(model); } return(list); }
public static void InitChartTypeComboBox(ASPxComboBox cbbChartType, ViewType chartTypeDefault, params string[] restricted_EndWith) { ViewType[] restrictedTypes = { ViewType.PolarArea, ViewType.PolarLine, ViewType.SideBySideGantt, ViewType.SideBySideRangeBar, ViewType.RangeBar, ViewType.Gantt, ViewType.PolarPoint, ViewType.Stock, ViewType.CandleStick, ViewType.Bubble }; if (restricted_EndWith != null && restricted_EndWith.Length > 0) { foreach (ViewType type in Enum.GetValues(typeof(ViewType))) { if (Array.IndexOf <ViewType>(restrictedTypes, type) >= 0) { continue; } var viewName = type.ToString(); if (restricted_EndWith.Exists(p => viewName.EndsWith(p))) { continue; } cbbChartType.Items.Add(viewName); } } else { foreach (ViewType type in Enum.GetValues(typeof(ViewType))) { if (Array.IndexOf <ViewType>(restrictedTypes, type) >= 0) { continue; } cbbChartType.Items.Add(type.ToString()); } } cbbChartType.SelectedItem = cbbChartType.Items.FindByText(chartTypeDefault.ToString()); cbbChartType.DropDownRows = GlobalVar.DropDownRow; }
public static void CreateAppearanceRuleNode(IModelClass modelClass, string id, string properties, EditorState editorState, string criteria, ViewType viewType, string methodName, int?index, ViewItemVisibility visibility) { if (modelClass is IModelConditionalAppearance) { IModelConditionalAppearance appearance = modelClass as IModelConditionalAppearance; IModelAppearanceRule targetRule = appearance.AppearanceRules.AddNode <IModelAppearanceRule>(id); targetRule.TargetItems = properties; switch (editorState) { case EditorState.Default: if (!String.IsNullOrEmpty(methodName)) { throw new ArgumentException(MethodNameMemberPresentErrorsMessage + "\r\nIn class: " + modelClass.Name + " Attribute.Id=" + id); } break; case EditorState.Disabled: targetRule.Enabled = false; break; case EditorState.Hidden: targetRule.Visibility = visibility; break; } targetRule.Criteria = criteria; targetRule.Method = methodName; targetRule.Context = viewType.ToString(); targetRule.Index = index; if (id.Contains(LayoutItemRuleTargetItemTypeMark)) { targetRule.AppearanceItemType = AppearanceItemType.LayoutItem.ToString(); } else { targetRule.AppearanceItemType = AppearanceItemType.ViewItem.ToString(); } } }
public static Autodesk.Revit.DB.View FindViewTemplateOrDefault(Document doc, ViewType viewType, string viewTemplateName, out bool templateIsFound) { // Get the view template List <Autodesk.Revit.DB.View> list = (from v in new FilteredElementCollector(doc) .OfClass(typeof(Autodesk.Revit.DB.View)) .Cast <Autodesk.Revit.DB.View>() where v.IsTemplate == true && v.ViewType == viewType && v.ViewName.Equals(viewTemplateName) select v).ToList(); Autodesk.Revit.DB.View template; if (list.Count != 0) { templateIsFound = true; template = list.First(); } else // Dont find the template, get any view template of the given type { templateIsFound = false; template = (from v in new FilteredElementCollector(doc) .OfClass(typeof(Autodesk.Revit.DB.View)) .Cast <Autodesk.Revit.DB.View>() where v.IsTemplate == true && v.ViewType == viewType select v).FirstOrDefault(); if (template == null) // Dont even find an existing view template in the doc { string msg = string.Format("Please ensure that there is at least one {0} template in the project!", viewType.ToString()); MessageBox.Show(msg, "No view template exists"); } } return(template); }
/// <summary> /// build the scheduler view grid model /// </summary> /// <returns></returns> public GridModelDto <SchedulerRow> Build() { var clientDate = HandleCommand(); DateTime periodStartClient, periodEndClient; GetPeriodForViewType(clientDate, out periodStartClient, out periodEndClient); var periodStartUtc = periodStartClient.AddMinutes(MinutesOffset); var periodEndUtc = periodEndClient.AddMinutes(MinutesOffset); var columns = GenerateColumnsForViewType(periodStartClient, periodEndClient); gridParams.Columns = columns.ToArray(); gridParams.Paging = false; var events = GetEvents(periodStartUtc, periodEndUtc).ToArray(); var rows = new List <SchedulerRow>(); if (IsDayLikeView()) { var allDayRow = new SchedulerRow { Time = "all day", AllDay = true }; var allDayCells = new List <DayCell>(); var daysCount = GetDaysCount(); for (var i = 0; i < daysCount; i++) { var dayStartUtc = periodStartUtc.AddDays(i); var allDayEvents = GetAllDayEvents(events, dayStartUtc); var cell = BuildCell(allDayEvents, dayStartUtc, ViewType.Value); allDayCells.Add(cell); } allDayRow.Cells = allDayCells; rows.Add(allDayRow); } if (ViewType == SchedulerView.Month) { var weeksInPeriod = Math.Ceiling((periodEndUtc - periodStartUtc).TotalDays / 7); for (var week = 0; week < weeksInPeriod; week++) { var row = new SchedulerRow(); var cells = new List <DayCell>(); for (var day = 0; day < 7; day++) { var dayEvents = GetDayEvents(events, periodStartUtc.AddDays(day + week * 7)); var cell = BuildCell(dayEvents, periodStartUtc.AddDays(day + week * 7), ViewType.Value); cells.Add(cell); } row.Cells = cells; rows.Add(row); } } else if (ViewType == SchedulerView.Agenda) { for (var day = periodStartUtc; day < periodEndUtc; day = day.AddDays(1)) { var clientDay = day.AddMinutes(-MinutesOffset); var dayEvents = GetDayEvents(events, day); rows.AddRange(dayEvents.Select(o => new SchedulerRow { Date = clientDay.ToString(Dformat.LongDatePattern), Time = AgendaTime(o, clientDay, MinutesOffset, Dformat), Title = o.Title, Notes = o.Notes, RowClass = "agendaRow" })); } } else if (IsDayLikeView()) { var minutes = 0; var minutesUpperBound = 24 * 60; var stepMinutes = HourStep ?? 30; if (HoursType == SchedulerHour.WorkingHours) { minutes = 8 * 60; minutesUpperBound = 20 * 60; } while (minutes < minutesUpperBound) { var row = new SchedulerRow(); var partHour = minutes / 60; var partMinute = minutes % 60; var timePartStartUtc = new DateTime( periodStartClient.Year, periodStartClient.Month, periodStartClient.Day, partHour, partMinute, 0).AddMinutes(MinutesOffset); // any date will do, only time is shown row.Time = (DateTime.UtcNow.Date + new TimeSpan(partHour, partMinute, 0)).ToString(Dformat.ShortTimePattern); var days = GetDaysCount(); var cells = new List <DayCell>(); for (var day = 0; day < days; day++) { var startUtc = timePartStartUtc.AddDays(day); var allDayIds = rows[0].Cells[day].Events.Select(o => o.Id); var timePartEvents = GetTimePartEvents( events, startUtc, startUtc.AddMinutes(stepMinutes), allDayIds); var cell = BuildCell(timePartEvents, startUtc, ViewType.Value); cells.Add(cell); } minutes += stepMinutes; row.Cells = cells; rows.Add(row); } } var model = new GridModelBuilder <SchedulerRow>(rows.AsQueryable(), gridParams) { FrozenRows = IsDayLikeView() ? 1 : 0, Tag = new { View = ViewType.ToString(), Date = clientDate.ToString(Dformat.ShortDatePattern), DateLabel = GetDateStr(clientDate, periodStartClient, periodEndClient) } }.Build(); return(model); }
public override void Execute() { var viewType = (CSAViewType)Enum.Parse(typeof(CSAViewType), ViewType.ToString()); switch (viewType) { case CSAViewType.Idle: View = new CompoundStructureAnnotationWindow(this); IntPtr rvtPtr = Autodesk.Windows.ComponentManager.ApplicationWindow; WindowInteropHelper helper = new WindowInteropHelper(View); helper.Owner = rvtPtr; View.ShowDialog(); break; case CSAViewType.Select: if (View.IsActive) { View.Close(); } using (PmSoft.Common.RevitClass.PickObjectsMouseHook MouseHook = new PmSoft.Common.RevitClass.PickObjectsMouseHook()) { MouseHook.InstallHook(PmSoft.Common.RevitClass.PickObjectsMouseHook.OKModeENUM.Objects); try { Model.TargetId = UIDocument.Selection.PickObject(ObjectType.Element , new VLClassesFilter(false, typeof(Wall), typeof(Floor), typeof(ExtrusionRoof), typeof(FootPrintRoof))).ElementId; MouseHook.UninstallHook(); ViewType = (int)CSAViewType.Generate; } catch (Exception ex) { MouseHook.UninstallHook(); ViewType = (int)CSAViewType.Idle; } } break; case CSAViewType.Generate: var doc = UIDocument.Document; if (VLTransactionHelper.DelegateTransaction(doc, "生成结构标注", () => { var element = doc.GetElement(Model.TargetId); var Collection = CSAContext.GetCollection(doc); //避免重复生成 由于一个对象可能在不同的视图中进行标注设置 所以还是需要重复生成的 var existedModel = Collection.Data.FirstOrDefault(c => c.TargetId.IntegerValue == Model.TargetId.IntegerValue); if (existedModel != null) { Collection.Data.Remove(existedModel); CSAContext.Creator.Clear(doc, existedModel); } var fontScale = 1 / VLConstraintsForCSA.OrientFontSizeScale * Model.CurrentFontSizeScale; Model.LineWidth = UnitHelper.ConvertToFoot(Model.CSALocationType.GetLineWidth() * fontScale, VLUnitType.millimeter); CSAContext.Creator.Generate(doc, Model, element); Collection.Data.Add(Model); Collection.Save(doc); return(true); })) { ViewType = (int)CSAViewType.Select; } else { ViewType = (int)CSAViewType.Idle; } break; case CSAViewType.Close: View.Close(); break; case CSAViewType.Closing: default: break; } }
/// <summary> /// Add a view to the list. /// </summary> /// <param name="isDefault">Represents whether this view is a default view.</param> /// <param name="queryType">Represents the type of query condition of the view.</param> /// <param name="viewType">Represents the type of the view to be created.</param> /// <returns>The GUID of the view, which is also called the view name.</returns> protected string AddView(bool isDefault, Query queryType, ViewType viewType) { string listName = TestSuiteBase.ListGUID; string viewName = this.GenerateRandomString(5); AddViewViewFields viewFields = new AddViewViewFields(); viewFields.ViewFields = this.GetViewFields(true); AddViewQuery addViewQuery = new AddViewQuery(); addViewQuery.Query = this.GetCamlQueryRoot(queryType, false); AddViewRowLimit rowLimit = new AddViewRowLimit(); rowLimit.RowLimit = this.GetAvailableRowLimitDefinition(); string type = string.Empty; switch (viewType) { case ViewType.Calendar: type = "Calendar"; break; case ViewType.Grid: type = "Grid"; break; case ViewType.Html: type = "Html"; break; default: Site.Debug.Fail("Not supported view type {0}", viewType.ToString()); break; } AddViewResponseAddViewResult addViewResponseAddViewResult = TestSuiteBase.Adapter.AddView( listName, viewName, viewFields, addViewQuery, rowLimit, type, isDefault); this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The call of the AddView operation SHOULD be successful."); string viewGUID = addViewResponseAddViewResult.View.Name; if (isDefault) { this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.DefaultView, "The response element \"addViewResponseAddViewResult.View.DefaultView\" should not be null."); this.Site.Assert.AreEqual("true", addViewResponseAddViewResult.View.DefaultView.ToLower(), "The added view should be a default view."); // If the new default view is added successfully, the original default view lost its default view position. if (OriginalDefaultViewName != null) { if (TestSuiteBase.OriginalDefaultViewLost == false) { TestSuiteBase.OriginalDefaultViewLost = true; } } } TestSuiteBase.ViewPool.Add(viewGUID); return(addViewResponseAddViewResult.View.Name); }
public override void Execute() { var viewType = (CMViewType)Enum.Parse(typeof(CMViewType), ViewType.ToString()); switch (viewType) { case CMViewType.Idle: View = new CMWindow(this); View.ShowDialog(); break; case CMViewType.Close: View.Close(); //SaveSetting(); break; case CMViewType.Closing: //SaveSetting(); break; case CMViewType.PickSinglePipe_Pipe: View.Close(); if (!VLHookHelper.DelegateKeyBoardHook(() => { //业务逻辑处理 //选择符合类型的过滤 var targetType = Model.GetFilter(); Model.TargetIds = new List <ElementId>() { UIDocument.Selection.PickObject(ObjectType.Element, targetType, "请选择管道标注点").ElementId }; if (Model.TargetIds.Count > 0) { ViewType = (int)CMViewType.PickSinglePipe_Location; } })) { ViewType = (int)CMViewType.Idle; } Execute(); break; case CMViewType.PickSinglePipe_Location: if (!VLHookHelper.DelegateKeyBoardHook(() => { ////业务逻辑处理 //var target = Document.GetElement(Model.TargetIds.First()); //var targetLocation = target.Location as LocationCurve; //var p0 = targetLocation.Curve.GetEndPoint(0); //var p1 = targetLocation.Curve.GetEndPoint(1); //var pStart = new XYZ((p0.X + p1.X) / 2, (p0.Y + p1.Y) / 2, (p0.Z + p1.Z) / 2); //var pEnd = new VLPointPicker().PickPointWithLinePreview(UIApplication, pStart); //if (pEnd == null) // ViewType = CMViewType.Idle; //else // ViewType = CMViewType.GenerateSinglePipe; })) { ViewType = (int)CMViewType.Idle; } Execute(); break; case CMViewType.GenerateSinglePipe: if (TransactionUtils.DelegateTransaction(Document, "GenerateSinglePipe", (Func <bool>)(() => { var element = Document.GetElement(Model.TargetIds.First()); var Collection = CMContext.GetCollection(Document); //避免重复生成 由于一个对象可能在不同的视图中进行标注设置 所以还是需要重复生成的 var existedModels = Collection.Data.Where(c => c.TargetIds.Intersect(Model.TargetIds, new ElementIdComparer()) != null); if (existedModels != null) { foreach (var existedModel in existedModels) { Collection.Data.Remove(existedModel); CMContext.Creator.Clear(Document, existedModel); } } CMContext.Creator.Generate(Document, Model, element); Collection.Data.Add(Model); Collection.Save(Document); return(true); }))) { ViewType = (int)CMViewType.PickSinglePipe_Pipe; } else { ViewType = (int)CMViewType.Idle; } Execute(); break; default: throw new NotImplementedException("功能未实现"); } }
public override void Execute() { PBPAModelCollection collection; var viewType = (PBPAViewType)Enum.Parse(typeof(PBPAViewType), ViewType.ToString()); switch (viewType) { case PBPAViewType.Idle: View = new PBPAWindow(this); View.ShowDialog(); break; case PBPAViewType.Close: View.Close(); SaveSetting(); break; case PBPAViewType.Closing: SaveSetting(); break; case PBPAViewType.RegenerateAllFor_L: VLTransactionHelper.DelegateTransaction(Document, "RegenerateAllFor_L", (Func <bool>)(() => { collection = PBPAContext.GetCollection(Document); for (int i = collection.Data.Count - 1; i >= 0; i--) { var model = collection.Data[i]; model.Document = Document; model.IsRegenerate = true; var element = Document.GetElement(model.TargetId); element.GetParameters(PBPAContext.SharedParameterPL).FirstOrDefault().Set(model.GetFull_L(element)); if (!PBPAContext.Creator.Regenerate(model)) { collection.Data.Remove(model); } } collection.Save(Document); return(true); })); ViewType = (int)PBPAViewType.Idle; break; case PBPAViewType.PickSingle_Target: UpdateSetting(); MemoHelper.UpdateDifference(Document, Setting, false); Model.Document = Document; Model.ViewId = Document.ActiveView.Id; View.Close(); if (!VLHookHelper.DelegateKeyBoardHook(() => { //业务逻辑处理 //选择符合类型的过滤 UpdateModelTargetType(); var targetType = Model.GetFilter(); var obj = UIDocument.Selection.PickObject(ObjectType.Element, targetType, "请选择标注点"); if (obj != null) { Model.TargetId = obj.ElementId; Model.TargetType = Model.IsPunch(Document.GetElement(obj.ElementId)) ? PBPATargetType.Punch : PBPATargetType.BranchPipe; ViewType = (int)PBPAViewType.PickSingle_End; Model.BodyStartPoint = obj.GlobalPoint; } })) { ViewType = (int)PBPAViewType.Idle; } //获取族内参数信息 if (!GetFamilySymbolInfo(Model.TargetId)) { ShowMessage("加载族信息失败"); ViewType = (int)PBPAViewType.Idle; Execute(); return; } Model.CurrentFontWidthSize = PBPAContext.FontManagement.CurrentFontWidthSize; Execute(); break; case PBPAViewType.PickSingle_End: //业务逻辑处理 if (!VLHookHelper.DelegateKeyBoardHook(() => { //var locationCurve = (target.Location as LocationCurve).Curve as Line; //XYZ vVector, pVector; //VLLocationHelper.GetVectors(locationCurve, CoordinateType.XY, out vVector, out pVector); #region 平面+立面支持 //CoordinateType coordinateType; //coordinateType = VLLocationHelper.GetCoordinateType(Document); //Model.CoordinateType = coordinateType; //var hVector = coordinateType.GetParallelVector(); //hVector = VLLocationHelper.GetVectorByQuadrant(hVector, QuadrantType.OneAndFour, coordinateType); //var vVector = VLLocationHelper.GetVerticalVector(hVector); //vVector = VLLocationHelper.GetVectorByQuadrant(vVector, QuadrantType.OneAndFour, coordinateType); #endregion VLCoordinateType coordinateType = VLCoordinateType.XY; Model.UpdateVector(coordinateType); var target = Document.GetElement(Model.TargetId); Model.UpdateLineWidth(target); var startPoint = Model.BodyStartPoint.ToWindowsPoint(coordinateType); var offSet = (Model.LineWidth * Model.ParallelVector).ToWindowsPoint(); //var endPoint = (Model.BodyStartPoint + Model.LineWidth * 1.02 * Model.ParallelVector).ToWindowsPoint(coordinateType); var pEnd = new VLPointPicker().PickPointWithPreview(UIApplication, coordinateType, (view) => { var mousePosition = System.Windows.Forms.Control.MousePosition; var midDrawP = new System.Windows.Point(mousePosition.X - view.Left, mousePosition.Y - view.Top); //中间选择点 var midPoint = view.ConvertToRevitPointFromDrawPoint(midDrawP); var startDrawP = view.ConvertToDrawPointFromRevitPoint(startPoint); //起点 var M_S = midPoint - Model.BodyStartPoint; if (Model.AnnotationType == PBPAAnnotationType.OneLine || Model.ParallelVector.CrossProductByCoordinateType(M_S, VLCoordinateType.XY) > 0) { var endPoint = startPoint.Plus(offSet); var endP = view.ConvertToDrawPointFromRevitPoint(endPoint); //终点 if (Math.Abs(startDrawP.X - midDrawP.X) < 2 && Math.Abs(startDrawP.Y - midDrawP.Y) < 2) { return; } var mid_s = midDrawP - startDrawP; mid_s.Normalize(); var midSDrawP = midDrawP - mid_s * view.co_s; var height = midDrawP - startDrawP; var endDrawP = endP + height; var mid_e = midDrawP - endDrawP; mid_e.Normalize(); var midEDrawP = midDrawP - mid_e * view.co_e; if (double.IsNaN(midEDrawP.X)) { return; } var canvas = view.canvas; canvas.Children.RemoveRange(0, canvas.Children.Count); var line = new System.Windows.Shapes.Line() { X1 = startDrawP.X, Y1 = startDrawP.Y, X2 = midSDrawP.X, Y2 = midSDrawP.Y, Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(136, 136, 136)), StrokeThickness = 1 }; var line2 = new System.Windows.Shapes.Line() { X1 = midEDrawP.X, Y1 = midEDrawP.Y, X2 = endDrawP.X, Y2 = endDrawP.Y, Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(136, 136, 136)), StrokeThickness = 1 }; System.Windows.Media.RenderOptions.SetBitmapScalingMode(line, System.Windows.Media.BitmapScalingMode.LowQuality); System.Windows.Media.RenderOptions.SetBitmapScalingMode(line2, System.Windows.Media.BitmapScalingMode.LowQuality); canvas.Children.Add(line); canvas.Children.Add(line2); Model.IsReversed = false; } else { var endPoint = startPoint.Minus(offSet); var endP = view.ConvertToDrawPointFromRevitPoint(endPoint); //终点 if (Math.Abs(startDrawP.X - midDrawP.X) < 2 && Math.Abs(startDrawP.Y - midDrawP.Y) < 2) { return; } var mid_s = midDrawP - startDrawP; mid_s.Normalize(); var midSDrawP = midDrawP - mid_s * view.co_s; var height = midDrawP - startDrawP; var endDrawP = endP + height; var mid_e = midDrawP - endDrawP; mid_e.Normalize(); var midEDrawP = midDrawP - mid_e * view.co_e; if (double.IsNaN(midEDrawP.X)) { return; } var canvas = view.canvas; canvas.Children.RemoveRange(0, canvas.Children.Count); var line = new System.Windows.Shapes.Line() { X1 = startDrawP.X, Y1 = startDrawP.Y, X2 = midSDrawP.X, Y2 = midSDrawP.Y, Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(136, 136, 136)), StrokeThickness = 1 }; var line2 = new System.Windows.Shapes.Line() { X1 = midEDrawP.X, Y1 = midEDrawP.Y, X2 = endDrawP.X, Y2 = endDrawP.Y, Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(136, 136, 136)), StrokeThickness = 1 }; System.Windows.Media.RenderOptions.SetBitmapScalingMode(line, System.Windows.Media.BitmapScalingMode.LowQuality); System.Windows.Media.RenderOptions.SetBitmapScalingMode(line2, System.Windows.Media.BitmapScalingMode.LowQuality); canvas.Children.Add(line); canvas.Children.Add(line2); Model.IsReversed = true; } }); if (pEnd == null) { ViewType = (int)PBPAViewType.Idle; } else { Model.BodyEndPoint = pEnd.ToSame(Model.BodyStartPoint, coordinateType); ViewType = (int)PBPAViewType.GenerateSingle; } })) { ViewType = (int)PBPAViewType.Idle; } Execute(); break; case PBPAViewType.GenerateSingle: //生成处理 if (VLTransactionHelper.DelegateTransaction(Document, "GenerateSingle", (Func <bool>)(() => { #region 生成处理 collection = PBPAContext.GetCollection(Document); var existedModels = collection.Data.Where(c => Model.TargetId == c.TargetId).ToList(); //避免重复生成 if (existedModels != null) { for (int i = existedModels.Count() - 1; i >= 0; i--) { existedModels[i].Document = Document; collection.Data.Remove(existedModels[i]); existedModels[i].Clear(); } } if (!PBPAContext.Creator.Generate(Model)) { return(false); } collection.Data.Add(Model); collection.Save(Document); #endregion #region 共享参数设置 var element = Document.GetElement(Model.TargetId); element.GetParameters(PBPAContext.SharedParameterPL).FirstOrDefault().Set(Model.GetFull_L(element)); #endregion return(true); }))) { ViewType = (int)PBPAViewType.PickSingle_Target; } else { ViewType = (int)PBPAViewType.Idle; } Execute(); break; case PBPAViewType.GenerateAll: default: throw new NotImplementedException("功能未实现"); } }
/// <summary> /// Creates the specified DAC type. /// </summary> /// <param name="type">The DAC type.</param> /// <param name="args">The args.</param> /// <returns></returns> public IViewModel Create(ViewType type, params object[] args) { // get attribuye value QualifiedTypeNameAttribute QualifiedNameAttr = EnumAttributeUtility <ViewType, QualifiedTypeNameAttribute> .GetEnumAttribute(type.ToString()); IViewModel instance = null; // create instance instance = (IViewModel)this.CreateObjectInstance(QualifiedNameAttr.AssemblyFileName, QualifiedNameAttr.QualifiedTypeName, args); return(instance); }
public MenuItem(ViewType viewType) { _viewType = viewType; _name = viewType.ToString(); }
public override string GetCommandName() { return("View " + _viewType.ToString().Replace("_", " ")); }
/// <summary> /// Navigate by ViewType. /// </summary> public void NavigateTo(ViewType viewType) { Page relativePageFromNavigationStack = Application.Current.MainPage.Navigation.NavigationStack.FirstOrDefault(p => p.GetType().Name == viewType.ToString()); if (relativePageFromNavigationStack != null) { MoveToTheExistingPageInNavigationStack(relativePageFromNavigationStack); } else { ApplyVisualChangesWhileNavigating(Application.Current.MainPage.Navigation.NavigationStack.LastOrDefault()); PushPage((Page)_viewContainer.GetViewByType(viewType)); } }
/// <summary> /// Add a view to the list. /// </summary> /// <param name="isDefault">Represents whether this view is a default view.</param> /// <param name="queryType">Represents the type of query condition of the view.</param> /// <param name="viewType">Represents the type of the view to be created.</param> /// <returns>The GUID of the view, which is also called the view name.</returns> protected string AddView(bool isDefault, Query queryType, ViewType viewType) { string listName = TestSuiteBase.ListGUID; string viewName = this.GenerateRandomString(5); AddViewViewFields viewFields = new AddViewViewFields(); viewFields.ViewFields = this.GetViewFields(true); AddViewQuery addViewQuery = new AddViewQuery(); addViewQuery.Query = this.GetCamlQueryRoot(queryType, false); AddViewRowLimit rowLimit = new AddViewRowLimit(); rowLimit.RowLimit = this.GetAvailableRowLimitDefinition(); string type = string.Empty; switch (viewType) { case ViewType.Calendar: type = "Calendar"; break; case ViewType.Grid: type = "Grid"; break; case ViewType.Html: type = "Html"; break; default: Site.Debug.Fail("Not supported view type {0}", viewType.ToString()); break; } AddViewResponseAddViewResult addViewResponseAddViewResult = TestSuiteBase.Adapter.AddView( listName, viewName, viewFields, addViewQuery, rowLimit, type, isDefault); this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The call of the AddView operation SHOULD be successful."); string viewGUID = addViewResponseAddViewResult.View.Name; if (isDefault) { this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.DefaultView, "The response element \"addViewResponseAddViewResult.View.DefaultView\" should not be null."); this.Site.Assert.AreEqual("true", addViewResponseAddViewResult.View.DefaultView.ToLower(), "The added view should be a default view."); // If the new default view is added successfully, the original default view lost its default view position. if (OriginalDefaultViewName != null) { if (TestSuiteBase.OriginalDefaultViewLost == false) { TestSuiteBase.OriginalDefaultViewLost = true; } } } TestSuiteBase.ViewPool.Add(viewGUID); return addViewResponseAddViewResult.View.Name; }
/// <summary> /// change view /// </summary> /// <param name="view"></param> /// <param name="parmeters"></param> public void ChangeView(ViewType viewtype) { m_CurrentView = viewtype; if (m_RegisteredViews.ContainsKey(viewtype)) { View view = m_RegisteredViews[viewtype]; foreach (View v in m_RegisteredViews.Values) { bool vis = v.Type == view.Type; if (v.BigControl != null) v.BigControl.Visible = vis; if (v.SmallControl!= null) v.SmallControl.Visible = vis; } m_BigContainer.Controls.Clear(); m_SmallContainer.Controls.Clear(); if(view.BigControl!=null) { m_BigContainer.Controls.Add(view.BigControl); view.BigControl.Dock = DockStyle.Fill; view.BigControl.Visible = true; } if(view.SmallControl!=null) { m_SmallContainer.Controls.Add(view.SmallControl); view.SmallControl.Dock = DockStyle.Fill; view.SmallControl.Visible = true; } } else throw new Exception("View " + viewtype.ToString() + " is not registered"); FireViewChanged(); }
// render the scene. public void Render() { if (GameEngine.IsInError || SurfaceId == 0 || Visible == false || Width == 0 || Height == 0 || Game == null) { return; } NativeObjectAdapter gameLevel = GameEngine.GetGameLevel(); try { NativeObjectAdapter game = Game.As <NativeObjectAdapter>(); GameEngine.SetGameLevel(game); GameEngine.SetRenderState(m_renderState); if (Game.RootGameObjectFolder.GameObjects.Count > 0) { GameEngine.Update(0, 0, true); } if (ResetCamera) { // save view type ViewTypes viewtype = this.ViewType; ViewType = ViewTypes.Perspective; Size sz = ClientSize; float aspect = (float)sz.Width / (float)sz.Height; IBoundable boundable = Game.RootGameObjectFolder.Cast <IBoundable>(); Sce.Atf.VectorMath.Sphere3F sphere = boundable.BoundingBox.ToSphere(); float nearZ = sphere.Radius * 0.01f; nearZ = Math.Min(0.1f, nearZ); Camera.SetPerspective( (float)Math.PI / 4, aspect, nearZ, sphere.Radius * 10.0f); Vec3F camPos = sphere.Center + new Vec3F(sphere.Radius, sphere.Radius, sphere.Radius) * 1.2f; Camera.Set(camPos, sphere.Center, new Vec3F(0, 1, 0)); ViewType = viewtype; ResetCamera = false; } GameEngine.Begin(SurfaceId, Camera.ViewMatrix, Camera.ProjectionMatrix); if (Game.RootGameObjectFolder.GameObjects.Count > 0) { GameEngine.RenderGame(); } string str = "View Type: " + ViewType.ToString(); GameEngine.DrawText2D(str, Util3D.CaptionFont, 1, 1, Color.White); GameEngine.End(); } finally { GameEngine.SetGameLevel(gameLevel); } }
public void VSG_ViewChange(ViewType view) { Console.WriteLine("View Changed: {0}", view.ToString()); this.toolStripStatusLabel1.Text = view.ToString(); }
private void ShowItemType(ViewType viewType) { object uiElement = Bag.FindName(viewType.ToString()); if (uiElement is DockPanel) { (uiElement as DockPanel).Visibility = System.Windows.Visibility.Visible; } }