public override void OnSelectionChanged(SceneNode[] selectedObjects) { base.OnSelectionChanged(selectedObjects); this.selectedLights.Clear(); this.lightType = null; foreach (SceneNode sceneNode in selectedObjects) { LightElement lightElement = sceneNode as LightElement; if (lightElement != null) { this.selectedLights.Add(lightElement); if (this.lightType == null) { this.lightType = (object)lightElement.TargetType; } else if (!object.Equals(this.lightType, (object)lightElement.TargetType)) { this.lightType = MixedProperty.Mixed; } } } this.OnPropertyChanged("IsAmbientLight"); this.OnPropertyChanged("IsPointLight"); this.OnPropertyChanged("IsDirectionalLight"); this.OnPropertyChanged("IsSpotLight"); }
public bool CanLinkLE(LightElement le, PopUpMessageVM messageVM) { bool result = true; if (Model is AN6UControlChannel) { if (LE_Count >= 1 && Model.PointType != le.PointType) { messageVM.Message = AppMessages.UniverseLinkMsg(); result = false; } } if (Model is NLPowerChannel) { if (Model.PointType != le.PointType) { messageVM.Message = AppMessages.LE_LinkMsg(); return(false); } } return(result); }
LightElementVM CreateLightElementVM(PointTypeEnum pointType) { LightElementVM leVM = null; LightElement le = new LightElement(pointType, AppContext.ControlSpace); le.Partition = AppContext.Partition; leVM = new LightElementVM(le); if (leVM.Model.ControlSpace.Prefix == "AN" || leVM.Model.ControlSpace.Prefix == "DX") { if (leVM.Model.PointType == PointTypeEnum.RGB) { leVM.ColorSequenceList = LightElement.ColorSequenseRGB; } if (leVM.Model.PointType == PointTypeEnum.RGBW) { leVM.ColorSequenceList = LightElement.ColorSequenseRGBW; } } return(leVM); }
private void SetLightTypeOnSelection(Type lightType) { if (this.selectedLights.Count == 0 || this.lightType != null && this.lightType.Equals((object)lightType)) { return; } this.lightType = (object)lightType; SceneViewModel viewModel = this.selectedLights[0].ViewModel; SceneElementSelectionSet elementSelectionSet = viewModel.ElementSelectionSet; List <KeyValuePair <LightElement, LightElement> > list = new List <KeyValuePair <LightElement, LightElement> >(); foreach (LightElement key in (IEnumerable <LightElement>)elementSelectionSet.GetFilteredSelection <LightElement>()) { if (!(key.TargetType == lightType)) { LightElement lightElement = (LightElement)key.ViewModel.CreateSceneNode(lightType); DocumentNode documentNode = (DocumentNode)null; if (typeof(SpotLight).Equals(lightType)) { DocumentNodePath valueAsDocumentNode = key.GetLocalValueAsDocumentNode(SpotLightElement.DirectionProperty); documentNode = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null; } else if (typeof(DirectionalLight).Equals(lightType)) { DocumentNodePath valueAsDocumentNode = key.GetLocalValueAsDocumentNode(DirectionalLightElement.DirectionProperty); documentNode = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null; } if (typeof(DirectionalLight).Equals(lightType)) { if (documentNode != null) { lightElement.SetValue(DirectionalLightElement.DirectionProperty, (object)documentNode); } } else if (typeof(PointLightBase).IsAssignableFrom(lightType)) { if (!typeof(PointLightBase).IsAssignableFrom(key.TargetType)) { lightElement.SetValue(LightElement.PositionProperty, (object)new Point3D(0.0, 0.0, 0.0)); lightElement.SetValue(LightElement.RangeProperty, (object)10.0); lightElement.SetValue(LightElement.ConstantAttenuationProperty, (object)1.0); lightElement.SetValue(LightElement.LinearAttenuationProperty, (object)0.0); lightElement.SetValue(LightElement.QuadraticAttenuationProperty, (object)0.0); } if (typeof(SpotLight).Equals(lightType)) { if (documentNode != null) { lightElement.SetValue(SpotLightElement.DirectionProperty, (object)documentNode); } lightElement.SetValue(SpotLightElement.OuterConeAngleProperty, (object)40.0); lightElement.SetValue(SpotLightElement.InnerConeAngleProperty, (object)30.0); } } list.Add(new KeyValuePair <LightElement, LightElement>(key, lightElement)); } } if (list.Count != 0) { using (SceneEditTransaction editTransaction = viewModel.Document.CreateEditTransaction(StringTable.UndoUnitChangeLightType)) { foreach (KeyValuePair <LightElement, LightElement> keyValuePair in list) { LightElement key = keyValuePair.Key; LightElement lightElement = keyValuePair.Value; viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)key); Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)key); elementSelectionSet.RemoveSelection((SceneElement)key); SceneElement parentElement = key.ParentElement; ISceneNodeCollection <SceneNode> collectionForProperty = parentElement.GetCollectionForProperty((IPropertyId)parentElement.GetPropertyForChild((SceneNode)key)); int index = collectionForProperty.IndexOf((SceneNode)key); collectionForProperty[index] = (SceneNode)lightElement; SceneElementHelper.ApplyProperties((SceneNode)lightElement, properties); elementSelectionSet.ExtendSelection((SceneElement)lightElement); } editTransaction.Commit(); } } this.OnPropertyChanged("IsAmbientLight"); this.OnPropertyChanged("IsPointLight"); this.OnPropertyChanged("IsDirectionalLight"); this.OnPropertyChanged("IsSpotLight"); }
public LightTimelineItem(TimelineItemManager timelineItemManager, LightElement element) : base(timelineItemManager, (Base3DElement)element) { }
public LightElementVM(LightElement model) { Model = model; _dataService = ViewModelLocator.DataService; }
public static int AsInt(this LightElement state) { return((int)state); }
public string SearchFull(int count, int offset, string by, string dir, string query = "all", string text = "", string tags = "", string user = "", string userType = "") { List <LightElement> Result = new List <LightElement>(); using (_connection = new SqlConnection(Global.WaifString)) { _connection.Open(); if (dir != "ASC") { dir = "DESC"; } switch (by) { case "Name": break; case "Popularity": break; default: by = "Id"; break; } var serializer = new JavaScriptSerializer(); string sortCommand = "ORDER BY " + by + " " + dir + " OFFSET " + offset.ToString() + " ROWS " + "FETCH NEXT " + count.ToString() + " ROWS ONLY"; string aCommand = "(SELECT Id, Name, Image, Popularity, N'Аниме' as Type FROM Anime WHERE (Popularity > -1) {0}) "; string wCommand = "(SELECT Id, Name, Image, Popularity, N'Персонаж' as Type FROM Waifu WHERE (Popularity > -1) {0}) "; string wStatement = ""; string aStatement = ""; if (user != "") { if (userType == "fav") { wStatement += "AND (Id IN (SELECT WaifuId FROM Favorites " + "WHERE UserId=(SELECT Id FROM Users WHERE " + "Name=N'" + user + "'))) "; } else { wStatement += "AND (Author=N'" + user + "') "; } query = "waifu"; } if (query == "unconfirmed") { wStatement += "AND (Confirmed != N'1') "; } if (query == "waifu" || query == "all") { wStatement += "AND (Confirmed = N'1') "; } text = text.Trim().Replace(",", "").Replace(" ", ""); tags = tags.Trim(',', ' '); if (!String.IsNullOrEmpty(text)) { wStatement += String.Format("AND ((Name LIKE N'%{0}%') OR (AlterNames LIKE N'%{0}%')) ", text);; aStatement += String.Format("AND (Name LIKE N'%{0}%') ", text); } if (!String.IsNullOrEmpty(tags)) { var fTags = tags.Split(','); var tagLine = ""; for (int i = 0; i < fTags.Length; i++) { tagLine = "AND (dbo.GetWaifuTagsString(Id) LIKE N'%{0}%') "; tagLine = String.Format(tagLine, fTags[i]); wStatement += tagLine; } query = "waifu"; } aCommand = String.Format(aCommand, aStatement); wCommand = String.Format(wCommand, wStatement); var execCommand = ""; if (query == "all" || query == "text") { execCommand = String.Format("{0} UNION {1} {2}", wCommand, aCommand, sortCommand); } if (query == "unconfirmed" || query == "waifu") { execCommand = wCommand + sortCommand; } if (query == "anime") { execCommand = aCommand + sortCommand; } using (var cmd = new SqlCommand(execCommand, _connection)) { using (var rd = cmd.ExecuteReader()) { while (rd.Read()) { LightElement wl = new LightElement(rd); wl.Type = rd["Type"].ToString(); Result.Add(wl); } } var sb = new StringBuilder(); serializer.Serialize(Result, sb); return(sb.ToString()); } } }