// These methods are not used, but they are very useful when developing the Design experience #if Development /// <summary> /// Adds a default column for each property in the data source /// </summary> public static void GenerateColumns(ModelItem dataGridModelItem, EditingContext context) { using (ModelEditingScope scope = dataGridModelItem.BeginEdit(Properties.Resources.Generate_Columns)) { // Set databinding related properties DataGridDesignHelper.SparseSetValue(dataGridModelItem.Properties[MyPlatformTypes.DataGrid.AutoGenerateColumnsProperty], false); // Get the datasource object dataSource = dataGridModelItem.Properties[MyPlatformTypes.DataGrid.ItemsSourceProperty].ComputedValue; if (dataSource != null) { foreach (ColumnInfo columnGenerationInfo in DataGridDesignHelper.GetColumnGenerationInfos(dataSource)) { ModelItem dataGridColumn = null; dataGridColumn = DataGridDesignHelper.CreateDefaultDataGridColumn(context, columnGenerationInfo); if (dataGridColumn != null) { dataGridModelItem.Properties[MyPlatformTypes.DataGrid.ColumnsProperty].Collection.Add(dataGridColumn); } } } scope.Complete(); } }
/// <summary> /// Initializes the default values for the ModelItem. /// </summary> /// <param name="modelItem">The ModelItem.</param> public override void InitializeDefaults(ModelItem modelItem) { if (modelItem == null) { throw new ArgumentNullException("modelItem"); } }
public void UnregisterObject(ModelItem modelItem) { if (items.Exists((i) => i == modelItem)) { modelItem.Dispose(); } }
/// <summary> /// Redirect the parent action. /// </summary> /// <param name="parent">The item being dragged in.</param> /// <param name="childType">The type of the item being dragged.</param> /// <returns>The new parent for the child.</returns> public override ModelItem RedirectParent(ModelItem parent, Type childType) { if (parent == null) { throw new ArgumentNullException("parent"); } if (childType == null) { throw new ArgumentNullException("childType"); } if (parent.Content != null && parent.Content.IsSet) { // if Expander has a content and if the content is a panel or a contentcontrol, let the content act as the parent ModelItem content = parent.Content.Value; if (content != null && (content.IsItemOfType(PlatformTypes.Panel.TypeId) || content.IsItemOfType(PlatformTypes.ContentControl.TypeId))) { return content; } else { _canParent = false; return parent; // Expander has a content already but its neither Panel nor ContentControl. } } // Expander doesnt have any content and now Expander itself acts as the parent return base.RedirectParent(parent, childType); }
/// <summary> /// Only one TabItem should have DesignTimeIsSelectedProperty set to true at a time. /// DesignTimeSelectedIndexProperty of TabControl should match with that of active tab. /// </summary> /// <param name="item">The ModelItem representing a TabItem.</param> private static void UpdateIsSelectedForOtherTabs(ModelItem item) { // item.Parent is Tabcontrol if (item.Parent != null && item.Parent.IsItemOfType(MyPlatformTypes.TabControl.TypeId)) { if (item.Parent.Content != null) { ModelItemCollection tabItemCollection = item.Parent.Content.Collection; if (tabItemCollection != null && tabItemCollection.Count > 0) { foreach (ModelItem tabItem in tabItemCollection) { if (tabItem != item) { // set designer property for other tabItem in TabControl to false. tabItem.SetDesignerProperty(DesignTimeIsSelectedProperty, false); } else { // This tabItem has been activated, update selectedIndex for Tabcontrol tabItem.Parent.SetDesignerProperty( TabControlDesignModeValueProvider.DesignTimeSelectedIndexProperty, tabItemCollection.IndexOf(tabItem)); } } } } } }
/// <summary> /// Removes all columns from the DataGrid /// </summary> public static void RemoveColumns(ModelItem dataGridModelItem, EditingContext editingContext) { using (ModelEditingScope scope = dataGridModelItem.BeginEdit(Properties.Resources.Remove_Columns)) { dataGridModelItem.Properties[MyPlatformTypes.DataGrid.ColumnsProperty].Collection.Clear(); scope.Complete(); } }
internal static IEnumerable<ModelFile> GetModels(ModelItem m) { foreach (var a in m.files) yield return a; foreach (ModelItem a in m.dirs) foreach (var b in GetModels(a)) yield return b; }
// Set any property defaults here public override void InitializeDefaults(ModelItem item) { if (item != null) { DataGridHelper.SparseSetValue(item.Properties["Width"], 180.0); DataGridHelper.SparseSetValue(item.Properties["Height"], 170.0); } }
/// <summary> /// Constructor for modifying an existing item /// </summary> /// <param name="item"></param> public ModifyItemChildWindow(DefaultScope.Item item) { InitializeComponent(); this.item = ContextModel.Instance.GetItem(item); this.Loaded += new RoutedEventHandler(ItemModifyChildWindow_Loaded); }
/// <summary> /// Sets the default property values for AccordionItem. /// </summary> /// <param name="item">The AccordionItem ModelItem.</param> public override void InitializeDefaults(ModelItem item) { // <AccordionItem Content="AccordionItem" Header="AccordionItem" /> string headerName = Extensions.GetMemberName<Silverlight::System.Windows.Controls.AccordionItem>(x => x.Header); string contentName = Extensions.GetMemberName<Silverlight::System.Windows.Controls.AccordionItem>(x => x.Content); item.Properties[headerName].SetValue(Properties.Resources.AccordionItem_Header); item.Properties[contentName].SetValue(Properties.Resources.AccordionItem_Content); }
protected override void Activate(ModelItem item) { // Create and add a new adorner panel wheelSegmentsPanel = new WheelSegmentAdornerPanel(item); Adorners.Add(wheelSegmentsPanel); base.Activate(item); }
/// <summary> /// Sets the default property values for Rating. /// </summary> /// <param name="item">SSWCDC.Rating ModelItem.</param> public override void InitializeDefaults(ModelItem item) { string propertyName; // <inputToolkit:Rating ItemCount="5"> propertyName = Extensions.GetMemberName<SSWC.Rating>(x => x.ItemCount); item.Properties[propertyName].SetValue(5); }
public WheelPanelDesignTimeCanvas(ModelItem item) { _item = item; this.Loaded += WheelSegmentAdornerPanel_Loaded; this.SizeChanged += WheelPanelDesignTimeCanvas_SizeChanged; item.PropertyChanged += Item_PropertyChanged; }
/// <summary> /// Constructor which takes the parent list for a new item /// </summary> /// <param name="list">Parent list for an item</param> public ModifyItemChildWindow(ModelList list) { InitializeComponent(); item = ContextModel.Instance.GetNewItem(list); NewItem = true; this.Loaded += new RoutedEventHandler(ItemModifyChildWindow_Loaded); }
/// <summary> /// Sets the default property values for GridSplitter. /// </summary> /// <param name="item">SSWC.GridSplitter ModelItem.</param> public override void InitializeDefaults(ModelItem item) { string propertyName; propertyName = Extensions.GetMemberName<SSWC.GridSplitter>(x => x.Width); item.Properties[propertyName].SetValue("10.0"); propertyName = Extensions.GetMemberName<SSWC.GridSplitter>(x => x.Height); item.Properties[propertyName].SetValue("100.0"); }
protected override void Activate(ModelItem item, DependencyObject view) { calendarModelItem = item; CreateAdornerPanel(); PlaceAdornerPanel(); SubscribeDesignerEvents(); base.Activate(item, view); }
// Set any property defaults here public override void InitializeDefaults(ModelItem item) { if (item != null) { DataGridDesignHelper.SparseSetValue(item.Properties[PlatformTypes.DataGrid.WidthProperty], 200.0); DataGridDesignHelper.SparseSetValue(item.Properties[PlatformTypes.DataGrid.HeightProperty], 200.0); DataGridDesignHelper.SparseSetValue(item.Properties[PlatformTypes.DataGrid.AutoGenerateColumnsProperty], false); } }
public ModelOperationAdorner(ModelItem adorned) : base(adorned) { collection = new VisualCollection(this); collection.Add(tl = GetResizeThumb("LT")); collection.Add(tr = GetResizeThumb("RT")); collection.Add(bl = GetResizeThumb("LB")); collection.Add(br = GetResizeThumb("RB")); collection.Add(handler = GetMoveThumb()); }
/// <summary> /// Creates a DataGridTemplateColumn ModelItem with default templates for this property /// </summary> internal static ModelItem CreateTemplateColumn(EditingContext context, ColumnInfo columnGenerationInfo, ModelItem dataGridColumn) { ModelItem displayDataTemplate = CreateDataTemplate(context, PlatformTypes.TextBlock.TypeId, PlatformTypes.TextBlock.TextProperty, columnGenerationInfo.PropertyInfo.Name); dataGridColumn.Properties[PlatformTypes.DataGridTemplateColumn.CellTemplateProperty].SetValue(displayDataTemplate); ModelItem editingDataTemplate = CreateDataTemplate(context, PlatformTypes.TextBox.TypeId, PlatformTypes.TextBox.TextProperty, columnGenerationInfo.PropertyInfo.Name); dataGridColumn.Properties[PlatformTypes.DataGridTemplateColumn.CellEditingTemplateProperty].SetValue(editingDataTemplate); return dataGridColumn; }
// Set any property defaults here public override void InitializeDefaults(ModelItem item) { if (item != null) { DataGridHelper.SparseSetValue(item.Properties["Width"], 200.0); DataGridHelper.SparseSetValue(item.Properties["Height"], 200.0); DataGridHelper.SparseSetValue(item.Properties["AutoGenerateColumns"], false); } }
// Set any property defaults here public override void InitializeDefaults(ModelItem item) { if (item != null) { // This will really cause a margin to be added. Size defaultsize = new Size(200, 200); DataGridHelper.SparseSetValue(item.Properties[FrameworkElement.WidthProperty], defaultsize.Width); DataGridHelper.SparseSetValue(item.Properties[FrameworkElement.HeightProperty], defaultsize.Height); } }
/// <summary> /// TabControl initializer. /// </summary> /// <param name="item">Model item for a TabControl.</param> /// <param name="context">Editing context.</param> public override void InitializeDefaults(ModelItem item, EditingContext context) { // Use SparseSetValue to avoid setting values to their defaults Util.SparseSetValue(item.Properties[MyPlatformTypes.FrameworkElement.WidthProperty], 200d); Util.SparseSetValue(item.Properties[MyPlatformTypes.FrameworkElement.HeightProperty], 100d); // Add a default TabItem ModelItem newTabItem = ModelFactory.CreateItem(context, MyPlatformTypes.TabItem.TypeId, CreateOptions.InitializeDefaults); item.Content.Collection.Add(newTabItem); }
/// <summary> /// Initializes default for the specified ModelItem. /// </summary> /// <param name="item">Specified ModelItem.</param> public override void InitializeDefaults(ModelItem item) { if (item == null) { throw new ArgumentNullException("item"); } // Set properties item.Properties["Header"].SetValue(typeof(MenuItem).Name); }
/// <summary> /// Set the value of IsSelected, update any other TabItems, /// and raise change notification. /// </summary> /// <param name="item">The ModelItem representing a TabItem.</param> /// <param name="value">Value of the TabItem's IsSelected property.</param> public static void SetDesignTimeIsSelected(ModelItem item, bool value) { // If we are setting this one to true, set all the others to false. if (value) { UpdateIsSelectedForOtherTabs(item); } item.SetDesignerProperty(DesignTimeIsSelectedProperty, value); Util.InvalidateProperty(item, MyPlatformTypes.TabItem.IsSelectedProperty); }
public ConnectorAdorner(ModelItem item) : base(item) { model = item.ContentObject; collection = new VisualCollection(this); // make thumbs for (int i = 0; i < model.Connectors.Length; i++) collection.Add(thumbs[i] = GetConnectorThumb(model.Connectors[i])); // do not use center currently thumbs[(int)ConnectorType.Center].Visibility = Visibility.Collapsed; }
public override void InitializeDefaults(ModelItem item) { using (ModelEditingScope batchedChange = item.BeginEdit("Creates Default Items")) { for (int j = 0; j < 2; j++) { ModelItem i = ModelFactory.CreateItem(item.Context, typeof(NavigationPaneItem), CreateOptions.InitializeDefaults, null); item.Properties["Items"].Collection.Add(i); } batchedChange.Complete(); } }
/// <summary> /// Determine whether the given control can be parented into a TabItem. /// </summary> /// <param name="parent">ModelItem representing the parent.</param> /// <param name="childType">The type of child item.</param> /// <returns>true if the specified parent can accept a child of the specified type; otherwise, false.</returns> public override bool CanParent(ModelItem parent, Type childType) { if (parent == null) { throw new ArgumentNullException("parent"); } if (childType == null) { throw new ArgumentNullException("childType"); } return _canParent; }
/// <summary> /// Initializes the default values for the ModelItem. /// </summary> /// <param name="modelItem">The ModelItem.</param> public override void InitializeDefaults(ModelItem modelItem) { if (modelItem == null) { throw new ArgumentNullException("modelItem"); } modelItem.Properties["Header"].SetValue(typeof(ToggleSwitch).Name); #if VISUAL_STUDIO_DESIGNER modelItem.Properties["Width"].SetValue(456d); modelItem.Properties["Height"].SetValue(111d); #endif }
/// <summary> /// Sets default initialization for the MetaPanel. /// </summary> /// <param name="item">Reference to MetaPanel item.</param> public override void InitializeDefaults(ModelItem item) { // Default to a wrap layout item.Properties["LayoutDefinitions"].Collection.Add(ModelFactory.CreateItem(item.Context, typeof(WrapLayout))); // Default to full animation fo child elements item.Properties["AnimateDefinitions"].Collection.Add(ModelFactory.CreateItem(item.Context, typeof(NewPositionAnimate))); item.Properties["AnimateDefinitions"].Collection.Add(ModelFactory.CreateItem(item.Context, typeof(NewOpacityAnimate))); item.Properties["AnimateDefinitions"].Collection.Add(ModelFactory.CreateItem(item.Context, typeof(MovePositionAnimate))); item.Properties["AnimateDefinitions"].Collection.Add(ModelFactory.CreateItem(item.Context, typeof(RemovePositionAnimate))); item.Properties["AnimateDefinitions"].Collection.Add(ModelFactory.CreateItem(item.Context, typeof(RemoveOpacityAnimate))); }
/// <summary> /// Determines whether an item may be dragged inside this panel. /// </summary> /// <param name="parent">The panel.</param> /// <param name="childType">The child.</param> /// <returns>True if the item may be parented.</returns> public override bool CanParent(ModelItem parent, Type childType) { if (parent == null) { throw new ArgumentNullException("parent"); } if (childType == null) { throw new ArgumentNullException("childType"); } return parent.IsItemOfType(_targetPanelType); }
public static bool ReplaceModelItem(this ModelItem toFind, object replaceWith) => ReplaceModelItem(toFind.Parent, toFind, replaceWith);
// The logic is similar to UpdateCloneReferences. // the difference is in this function, we need to set reference by Property. void UpdateCloneReferenceByModelItem(FlowNode currentFlowElement, Dictionary <FlowNode, ModelItem> modelItems, Dictionary <FlowNode, FlowNode> clonedFlowElements) { if (typeof(FlowStep).IsAssignableFrom(currentFlowElement.GetType())) { FlowStep currentFlowStep = (FlowStep)currentFlowElement; FlowStep clonedFlowStep = (FlowStep)clonedFlowElements[currentFlowElement]; ModelItem modelItem = modelItems[clonedFlowStep]; FlowNode nextFlowElement = currentFlowStep.Next; if (nextFlowElement != null && clonedFlowElements.ContainsKey(nextFlowElement)) { modelItem.Properties["Next"].SetValue(clonedFlowElements[nextFlowElement]); } else { modelItem.Properties["Next"].SetValue(null); } } else if (typeof(FlowDecision).IsAssignableFrom(currentFlowElement.GetType())) { if (!modelItems.ContainsKey(currentFlowElement)) { Fx.Assert("Should not happen."); } FlowDecision currentFlowDecision = (FlowDecision)currentFlowElement; FlowDecision clonedFlowDecision = (FlowDecision)clonedFlowElements[currentFlowElement]; Fx.Assert(currentFlowDecision == clonedFlowDecision, "should not happen"); ModelItem modelItem = modelItems[currentFlowElement]; Fx.Assert(modelItem != null, "should not happen"); FlowNode trueElement = currentFlowDecision.True; FlowNode falseElement = currentFlowDecision.False; if (trueElement != null && clonedFlowElements.ContainsKey(trueElement)) { modelItem.Properties["True"].SetValue(clonedFlowElements[trueElement]); } else { modelItem.Properties["True"].SetValue(null); } if (falseElement != null && clonedFlowElements.ContainsKey(falseElement)) { modelItem.Properties["False"].SetValue(clonedFlowElements[falseElement]); } else { modelItem.Properties["False"].SetValue(null); } } else if (GenericFlowSwitchHelper.IsGenericFlowSwitch(currentFlowElement.GetType())) { GenericFlowSwitchHelper.ReferenceCopy(currentFlowElement.GetType().GetGenericArguments()[0], currentFlowElement, modelItems, clonedFlowElements); } else { Debug.Fail("Unknown FlowNode"); } }
/// <summary> /// Extension method that returns a list of tags of ModelItem object. /// </summary> /// <param name="modelItem"></param> /// <returns></returns> internal static IList <string> GetTags(this ModelItem modelItem) { return(modelItem.Tags.Split(',')); }
public UnzipDesignerViewModel(ModelItem modelItem) : base(modelItem, "Zip Name", "Destination") { AddTitleBarLargeToggle(); HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_File_Unzip; }
public static void SetArmText(ModelItem decisionActivity, Dev2DecisionStack dds) { SetArmText(decisionActivity, GlobalConstants.TrueArmPropertyText, dds.TrueArmText); SetArmText(decisionActivity, GlobalConstants.FalseArmPropertyText, dds.FalseArmText); }
public CopyDesignerViewModel(ModelItem modelItem) : base(modelItem, "File or Folder", "Destination") { AddTitleBarLargeToggle(); HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_File_Copy; }
public override bool Contains(ModelItem item) { return(this.sceneNodeCollection.Contains(((ISceneNodeModelItem)item).SceneNode)); }
public SharePointCopyFileDesignerViewModel(ModelItem modelItem, IAsyncWorker asyncWorker, IServer envModel) : base(modelItem, asyncWorker, envModel, EventPublishers.Aggregator, false) { HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_SharePoint_Copy_File; }
public static bool Is <T>(this ModelItem modelItem) where T : Activity => modelItem?.ItemType == typeof(T);
public abstract void OnSelectionChanged(ModelItem oldItem, ModelItem newItem);
public static object ArgumentMorphHelper(ModelItem originalValue, ModelProperty newModelProperty) { Type expressionTypeArgument = newModelProperty.PropertyType.GetGenericArguments()[0]; return(MorphArgument(originalValue, expressionTypeArgument)); }
public override void InitializeDefaults(ModelItem item) { item.Properties[nameof(DataGrid.Height)].SetValue(50d); item.Properties[nameof(DataGrid.Width)].SetValue(100d); }
// Returns collection of positions that describe this placement of the item. public override RelativeValueCollection GetPlacement(ModelItem item, params RelativePosition[] positions) { RelativeValueCollection bounds = new RelativeValueCollection(); return(bounds); }
public override int IndexOf(ModelItem item) { return(this.sceneNodeCollection.IndexOf(((ISceneNodeModelItem)item).SceneNode)); }
private static List <ModelItem> GetChildren(ModelItem modelItem) { var neighbors = new List <ModelItem>(); // do not search through Type and its derivatives if (typeof(Type).IsAssignableFrom(modelItem.ItemType)) { return(neighbors); } if (modelItem is ModelItemCollection collection) { neighbors.AddRange(collection.Where(m => m != null)); } var dictionary = modelItem as ModelItemDictionary; if (dictionary != null) { foreach (var kvp in dictionary) { var miKey = kvp.Key; if (miKey != null) { neighbors.Add(miKey); } var miValue = kvp.Value; if (miValue != null) { neighbors.Add(miValue); } } } foreach (var property in modelItem.Properties) { if (dictionary != null && string.Equals(property.Name, "ItemsCollection")) { // Don't search the item collection since we already search the items above. continue; } // we don't want to even try to get the value for a value type property // because that will create a new ModelItem every time. // System.Type has properties that throw when we try to get value // we don't want to expand system.type further during a search. if (typeof(Type).IsAssignableFrom(property.PropertyType) || property.PropertyType.IsValueType) { continue; } if (property.Value != null) { neighbors.Add(property.Value); } } return(neighbors); }
//ModelItem Modelitem; public SqlBulkInsertDesignerViewModel(ModelItem modelItem) : this(modelItem, new AsyncWorker(), EnvironmentRepository.Instance.ActiveEnvironment, EventPublishers.Aggregator) { // Modelitem = modelItem; }
// Return HashSet containing ModelItems found only through given property: Cannot reach property.Parent without // hitting property from these immediate descendents of property.Value // Set may contain some internal duplication -- all nodes, not just the root, of a linked tree will be included // // Caveat 1: Due to problems removing Parents (e.g. Case content sometimes holds references to FlowSwitch after // Case removed), this method is not entirely reliable -- customers may occasionally need to reopen Designer // Caveat 2: Due to lazy loading of Properties (and therefore the back-pointing Parents collection), may // temporarily include non-unique ModelItems in returned set -- cleared as tree or designer views expand // // (Throughout, cannot use ModelItem.GetParentEnumerator because that does not check all Sources and Parents) internal static HashSet <ModelItem> FindUniqueChildren(ModelProperty property) { HashSet <ModelItem> retval = new HashSet <ModelItem>(); if (null != property && null != property.Parent && null != property.Value) { ModelItem target = property.Parent; ModelItem expected = property.Value; HashSet <ModelItem> visited = new HashSet <ModelItem>(); // Check all immediate children of property.Value ModelItemCollection collection = expected as ModelItemCollection; if (null == collection) { ModelItemDictionary dictionary = expected as ModelItemDictionary; if (null == dictionary) { // ModelItem // Can't use UniqueRoute because we're starting at expected // Can't use EnqueueParents because we need to special-case given property // Instead confirm property.Value is not referenced anywhere else ModelItemImpl expectedImpl = expected as ModelItemImpl; if (null != expectedImpl) { bool justThisSource = true; // expectedImpl.InternalParents does not include ModelItems that are just Sources if (0 == expectedImpl.InternalParents.Count) { // expectedImpl.InternalSources would be similar but adds a wrapper we don't need here foreach (ModelProperty source in expected.Sources) { if (null != source.Parent && !visited.Contains(source.Parent)) { visited.Add(source.Parent); if (!property.Equals(source) && !expected.Equals(source) && null == ExtensibilityAccessor.GetAttribute <HidePropertyInOutlineViewAttribute>(source)) { // Found a non-ignored property from somewhere else referencing expected justThisSource = false; break; } } } } else { // Found a Parent that's not a Source.Parent: property.Value is in some collection justThisSource = false; } if (justThisSource) { retval.Add(expected); } } } else { // ModelItemDictionary foreach (KeyValuePair <ModelItem, ModelItem> child in dictionary) { if (null != child.Key && !visited.Contains(child.Key)) { visited.Add(child.Key); if (UniqueModelItemHelper.UniqueRoute(child.Key, target, expected)) { retval.Add(child.Key); } } if (null != child.Value && !visited.Contains(child.Value)) { visited.Add(child.Value); if (UniqueModelItemHelper.UniqueRoute(child.Value, target, expected)) { retval.Add(child.Value); } } } } } else { // ModelItemCollection foreach (ModelItem child in collection) { if (null != child && !visited.Contains(child)) { visited.Add(child); if (UniqueModelItemHelper.UniqueRoute(child, target, expected)) { retval.Add(child); } } } } } return(retval); }
public RenameDesignerViewModel(ModelItem modelItem) : base(modelItem, "File or Folder", "New Name") { AddTitleBarLargeToggle(); AddTitleBarHelpToggle(); }
public static ModelItem GetClosestBefore(this ModelItem root, Type matchingType, ModelItem refModelItem) => FindBefore(root, m => m.ItemType == matchingType, m => m == refModelItem).LastOrDefault();
/// <summary> /// Set the value of CurrentSelectedIndex. /// </summary> /// <param name="item">The model item for a TabControl.</param> /// <param name="value">CurrentSelectedIndex of the TabControl.</param> public static void SetCurrentSelectedIndexPropertyValue(ModelItem item, int value) { item.SetDesignerProperty(CurrentSelectedIndexValueProperty, value); }
//DETERMINES WHAT HIERARCHY LEVEL TO ACCESS PROPERTIES //BASED ON USER INPUT (classType - BUILDING SYSTEM (File), SYSTEM PARTS (Layer), or INDIVIDUAL COMPONENETS (Block)). //DIRECTION FROM GetSystemProperties Method. private static void ClassTypeCheck_Export(ModelItem mItem, string classType, string CurrDis, string CurrModelFile, string UserExportCat) { try { string CurrExportLvl; string CurrExportCat; string CurrGuid; string CurrEleName; //WILL LOOP THROUGH SELECTED FILE AND ALL SUB GEOMTRY ITEMS USING DescendantsAndSelf PROPERTY foreach (ModelItem subItem1 in mItem.DescendantsAndSelf) { string type = ""; switch (classType) { case "1": //"File" type = "File"; CurrExportLvl = "Overall System"; if (subItem1.ClassDisplayName == type) { //SETS CURRENT MODEL ITEM REQUIRED PROPERTIES FOR EXPORT //AND PASSES TO NEXT METHOD CurrExportCat = UserExportCat; CurrEleName = subItem1.DisplayName; CurrGuid = subItem1.InstanceGuid.ToString(); CategoryTypes_NullCheck(subItem1, CurrDis, CurrModelFile, CurrExportCat, CurrEleName, CurrGuid, CurrExportLvl); } break; case "2": //"Layer" type = "Layer"; CurrExportLvl = "Part Types"; //CHECK CONDITION IF MODEL AS EXPORTED FROM AUTOCAD //IN THIS CASE, MODEL ITEM IS OF TYPE LAYER if (subItem1.ClassDisplayName == type || subItem1.IsLayer == true) { bool validLayer = false; foreach (ModelItem obj in subItem1.Children) { if (obj.IsCollection == false) { validLayer = true; } } if (validLayer == true) { //SETS CURRENT MODEL ITEM REQUIRED PROPERTIES FOR EXPORT //AND PASSES TO NEXT METHOD CurrExportCat = UserExportCat; CurrEleName = subItem1.DisplayName; CurrGuid = subItem1.InstanceGuid.ToString(); CategoryTypes_NullCheck(subItem1, CurrDis, CurrModelFile, CurrExportCat, CurrEleName, CurrGuid, CurrExportLvl); } } //CHECKS CONDITION WHEN MODEL IS EXPORTED FROM REVIT //IN THIS CASE, REFER TO COLLECTION IF PARENT IS COLLECTION BUT CHILDREN ARE OF DIFFERENT TYPE //(E.G. COMPOSITE, INSERT, GEOMETRY, ETC.) else if (subItem1.IsCollection == true && subItem1.Parent.IsCollection == true) { bool validCollection = false; foreach (ModelItem obj in subItem1.Children) { if (obj.IsCollection == false) { validCollection = true; } } if (validCollection == true) { //SETS CURRENT MODEL ITEM REQUIRED PROPERTIES FOR EXPORT //AND PASSES TO NEXT METHOD CurrExportCat = UserExportCat; CurrEleName = subItem1.DisplayName; CurrGuid = subItem1.InstanceGuid.ToString(); CategoryTypes_NullCheck(subItem1, CurrDis, CurrModelFile, CurrExportCat, CurrEleName, CurrGuid, CurrExportLvl); } } break; case "3": //Block type = "Block"; CurrExportLvl = "Individual Components"; //CHECK CONDITION IF MODEL WAS EXPORTED FROM REVIT //IN THIS CASE, MODEL ITEM CLASS TYPE WILL BE BLOCK OR COMPOSITE if ((subItem1.ClassDisplayName == type || subItem1.IsComposite == true) && subItem1.IsInsert == false) { //SETS CURRENT MODEL ITEM REQUIRED PROPERTIES FOR EXPORT //AND PASSES TO NEXT METHOD if (subItem1.DisplayName == "") { CurrEleName = subItem1.ClassDisplayName; } else { CurrEleName = subItem1.DisplayName; } CurrExportCat = UserExportCat; CurrGuid = subItem1.InstanceGuid.ToString(); CategoryTypes_NullCheck(subItem1, CurrDis, CurrModelFile, CurrExportCat, CurrEleName, CurrGuid, CurrExportLvl); } //CHECK CONDITION IF MODEL WAS EXPORTED FROM AUTOCAD //IN THIS CASE, MODEL ITEM IS OF TYPE GEOMETRY DIRECT SUB TO LAYER SO CHECKS IF PARENT IS LAYER //AND RULES OUT OTHER TYPES. else if (subItem1.Parent.IsLayer == true && subItem1.IsInsert == false && subItem1.IsComposite == false && subItem1.IsCollection == false && subItem1.ClassDisplayName != "Block") { //SETS CURRENT MODEL ITEM REQUIRED PROPERTIES FOR EXPORT //AND PASSES TO NEXT METHOD //MessageBox.Show(subItem1.DisplayName); //MessageBox.Show(subItem1.ClassDisplayName); if (subItem1.DisplayName == "") { CurrEleName = subItem1.ClassDisplayName; } else { CurrEleName = subItem1.DisplayName; } CurrExportCat = UserExportCat; CurrGuid = subItem1.InstanceGuid.ToString(); CategoryTypes_NullCheck(subItem1, CurrDis, CurrModelFile, CurrExportCat, CurrEleName, CurrGuid, CurrExportLvl); } break; } } } catch (Exception exception) { MessageBox.Show("Error! Original Message: " + exception.Message); } }
public static ModelItem GetClosestBefore <T>(this ModelItem root, ModelItem refModelItem) => GetClosestBefore(root, typeof(T), refModelItem);
IEnumerable <IActionableErrorInfo> ValidateVariables() { var parser = new Dev2DataLanguageParser(); var error = ValidateVariable(parser, BatchSize, () => IsBatchSizeFocused = true); if (error != null) { error.Message = "Batch Size " + error.Message; yield return(error); } error = ValidateVariable(parser, Timeout, () => IsTimeoutFocused = true); if (error != null) { error.Message = "Timeout " + error.Message; yield return(error); } error = ValidateVariable(parser, Result, () => IsResultFocused = true); if (error != null) { error.Message = "Result " + error.Message; yield return(error); } foreach (var dc in GetInputMappings()) { var output = dc.OutputColumn; var inputColumn = dc.InputColumn; bool identityChecked = false; if (output.IsAutoIncrement) { if (KeepIdentity && string.IsNullOrEmpty(inputColumn)) { var msg = string.Format(ActivityResources.IdentityWithKeepOptionEnabledMsg, output.ColumnName); yield return(new ActionableErrorInfo(() => IsInputMappingsFocused = true) { ErrorType = ErrorType.Critical, Message = msg }); } if (!KeepIdentity && !string.IsNullOrEmpty(inputColumn)) { var msg = string.Format(ActivityResources.IdentityWithKeepOptionDisabledMsg, output.ColumnName); yield return(new ActionableErrorInfo(() => IsInputMappingsFocused = true) { ErrorType = ErrorType.Critical, Message = msg }); } identityChecked = true; } if (!output.IsNullable && string.IsNullOrEmpty(inputColumn) && !identityChecked) { var msg = string.Format(ActivityResources.NotNullableMsg, output.ColumnName); yield return(new ActionableErrorInfo(() => IsInputMappingsFocused = true) { ErrorType = ErrorType.Critical, Message = msg }); } error = ValidateVariable(parser, inputColumn, () => IsInputMappingsFocused = true); if (error != null) { error.Message = "Input Mapping To Field '" + output.ColumnName + "' " + error.Message; yield return(error); } if (!identityChecked) { List <IActionableErrorInfo> rs = GetRuleSet("InputColumn", inputColumn).ValidateRules("'Input Data or [[Variable]]'", () => ModelItem.SetProperty("IsMappingFieldFocused", true)); foreach (var looperror in rs) { yield return(looperror); } } } }
public void OnItemsPasted(List <object> itemsToPaste, List <object> metaData, Point pastePoint, WorkflowViewElement pastePointReference) { Fx.Assert(this.panel != null, "This code shouldn't be hit if panel is null"); HashSet <Activity> workflowElementsPasted = new HashSet <Activity>(); List <ModelItem> modelItemsToSelect = new List <ModelItem>(); bool shouldStoreCurrentSizeViewState = true; Fx.Assert(this.ModelItem is IModelTreeItem, "this.ModelItem must implement IModelTreeItem"); using (EditingScope editingScope = ((IModelTreeItem)this.ModelItem).ModelTreeManager.CreateEditingScope(System.Activities.Presentation.SR.CollectionAddEditingScopeDescription)) { if (metaData != null) { List <ModelItem> modelItemsPerMetaData = new List <ModelItem>(); foreach (object designerMetaData in metaData) { if (designerMetaData is List <FlowNode> ) { //This is flowchart metadata. foreach (FlowNode element in designerMetaData as List <FlowNode> ) { FlowStep step = element as FlowStep; if (step != null) { workflowElementsPasted.Add(step.Action); } if (shouldStoreCurrentSizeViewState) { // Pasting may change the size of flowchart; need this to undo the size change. this.StoreCurrentSizeViewStateWithUndo(); shouldStoreCurrentSizeViewState = false; } ModelItem item = this.ModelItem.Properties["Nodes"].Collection.Add(element); // if the pasted item is a flowswitch but the default target is not in the pasted selection, // reset the DefaultCaseDisplayName to "Default". if (GenericFlowSwitchHelper.IsGenericFlowSwitch(item.ItemType) && item.Properties["Default"].Value == null) { item.Properties[FlowSwitchLabelFeature.DefaultCaseDisplayNamePropertyName].SetValue(FlowSwitchLabelFeature.DefaultCaseDisplayNameDefaultValue); } modelItemsPerMetaData.Add(item); if (item != null) { if (item.ItemType.Equals(typeof(FlowStep))) { modelItemsToSelect.Add(item.Properties["Action"].Value); } else { modelItemsToSelect.Add(item); } } } if (pastePoint.X > 0 && pastePoint.Y > 0) { Point panelPoint = this.TranslatePoint(pastePoint, this.panel); if (pastePointReference != null && !pastePointReference.Equals(this)) { if (pastePointReference.ModelItem != null && this.modelElement.ContainsKey(pastePointReference.ModelItem)) { panelPoint = pastePointReference.TranslatePoint(pastePoint, this.panel); } } panelPoint.X = panelPoint.X < 0 ? 0 : panelPoint.X; panelPoint.Y = panelPoint.Y < 0 ? 0 : panelPoint.Y; UpdateViewStateOnPastePoint(modelItemsPerMetaData, panelPoint); } else { UpdateViewStateToAvoidOverlapOnPaste(modelItemsPerMetaData); } modelItemsPerMetaData.Clear(); } } } foreach (object itemToPaste in itemsToPaste) { Activity workflowElementToPaste = itemToPaste as Activity; if (workflowElementToPaste != null && !workflowElementsPasted.Contains(workflowElementToPaste)) { FlowStep flowStep = new FlowStep { Action = workflowElementToPaste, Next = null }; if (shouldStoreCurrentSizeViewState) { // Pasting may change the size of flowchart; need this to undo the size change. this.StoreCurrentSizeViewStateWithUndo(); shouldStoreCurrentSizeViewState = false; } // When paste a non-flowstep object to flowchart, the existing hintsize of the object // should be removed, and let flowchart panel to compute the right size. VirtualizedContainerService.SetHintSize(workflowElementToPaste, null); ModelItem flowStepItem = this.ModelItem.Properties["Nodes"].Collection.Add(flowStep); if (flowStepItem != null) { modelItemsToSelect.Add(flowStepItem.Properties["Action"].Value); } } } editingScope.Complete(); } this.Dispatcher.BeginInvoke(() => { if (modelItemsToSelect.Count > 0 && modelItemsToSelect[0] != null) { Keyboard.Focus(modelItemsToSelect[0].View as IInputElement); } this.Context.Items.SetValue(new Selection(modelItemsToSelect)); }, DispatcherPriority.ApplicationIdle ); }
/// <summary> /// Clear the value of SelectedIndex and raise change notification. /// </summary> /// <param name="item">Model item.</param> public static void ClearDesignTimeSelectedIndex(ModelItem item) { item.ClearDesignerProperty(DesignTimeSelectedIndexProperty); // Note: ClearDesignerProperty etc. are extension methods declared on DesignerState Util.InvalidateProperty(item, MyPlatformTypes.TabControl.SelectedIndexProperty); }
public static IEnumerable <ModelItem> GetChildren <T>(this ModelItem root) where T : Activity { var type = typeof(T); return(FindBreadthFirst(root, m => type == m.ItemType).ToList()); }
public SharePointCopyFileDesignerViewModel(ModelItem modelItem) : this(modelItem, new AsyncWorker(), ServerRepository.Instance.ActiveServer) { }
// Sets the given set of positions into the item. public override void SetPlacements(ModelItem item, PlacementIntent intent, params RelativeValue[] positions) { }
public TestDeleteDesignerViewModel(ModelItem modelItem) : base(modelItem) { }
protected override IEnumerable <IActionableErrorInfo> ValidateCollectionItem(ModelItem mi) { yield break; }