コード例 #1
0
        public BulkBranchForm(IBaseNode variables)
        {
            InitializeComponent();
            Variables = variables;

            InitializeControl();
        }
コード例 #2
0
        public BulkImportForm(IBaseNode variables, IApplication app, string modelFile, eImportMode mode = eImportMode.Link)
        {
            App = app;

            ImportMode = mode;

            InitializeComponent();
            DestVariables      = variables;
            tbxSourceFile.Text = modelFile;

            switch (ImportMode)
            {
            case eImportMode.Import:
                Text       = UI_Constants.BulkImportText;
                btnOk.Text = UI_Constants.BulkImportButton;
                break;

            case eImportMode.Link:
                Text       = UI_Constants.BulkLinkText;
                btnOk.Text = UI_Constants.BulkLinkButton;
                break;

            case eImportMode.Template:
                Text       = UI_Constants.BulkTemplateText;
                btnOk.Text = UI_Constants.BulkTemplateButton;
                break;
            }
        }
コード例 #3
0
        private void handle_DragDrop(object sender, DragEventArgs e)
        {
            IBaseNode baseNode = getTreeNodeFromDragEventArgs(e);

            if (baseNode != null)
            {
                Point insertPoint = PointToClient(new Point(e.X, e.Y));
                Point lastChar    = GetPositionFromCharIndex(Text.Length);
                log.Debug(lastChar.ToString());

                int index = GetCharIndexFromPosition(lastChar);
                if (index < 0)
                {
                    index = Text.Length;
                }

                Select(index, 0);

                Color tempColor     = SelectionColor;
                Color tempBackColor = SelectionBackColor;
                SelectionColor     = BaseNodeColor;
                SelectionBackColor = BaseNodeBackColor;
                SelectedText       = baseNode.Name;
                SelectionColor     = tempColor;
                SelectionBackColor = tempBackColor;

                Select(index + baseNode.Name.Length, 0);
            }
        }
コード例 #4
0
        public MethodsFromModelForm(IBaseNode selectedNode)
        {
            InitializeComponent();

            lbxAvailable.DrawItem += lbxAvailable_DrawItem;
            lbxSelected.DrawItem  += lbxAvailable_DrawItem;

            IDecisionTree tree = selectedNode.Tree;

            AddMethodsToAvailable(tree.RootNode);

            //Add Stock methods
            IConfigurationItem stockMethods = ConfigurationRepository.IConfiguration.GetConfigurationItem(UI_Constants.StockMethods);

            if (stockMethods != null)
            {
                foreach (IConfigurationItem it in stockMethods.ConfigurationItems)
                {
                    if (!HasItem(it.GetValue("")))
                    {
                        lbxAvailable.Items.Add(new ListBoxItem(it.GetValue(""), 1));
                    }
                }
            }

            toolTip.SetToolTip(btnOk, UI_Constants.CommitEnumToolTip);
            toolTip.SetToolTip(btnClose, UI_Constants.RevertEnumToolTip);

            toolTip.SetToolTip(btnAdd, UI_Constants.AddEnumToolTip);
            toolTip.SetToolTip(btnRemove, UI_Constants.RemoveEnumToolTip);
            toolTip.SetToolTip(btnNew, UI_Constants.NewEnumToolTip);
            toolTip.SetToolTip(btnMoveUp, UI_Constants.MoveUpEnumToolTip);
            toolTip.SetToolTip(btnMoveDown, UI_Constants.MoveDownEnumToolTip);
        }
コード例 #5
0
ファイル: DiagramModel.cs プロジェクト: Yuri05/OSPSuite.Core
 internal void RemoveNodeId(IBaseNode baseNode)
 {
     if (baseNode != null && _nodes.Contains(baseNode.Id))
     {
         _nodes.Remove(baseNode.Id);
     }
 }
コード例 #6
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (svc != null)
            {
                IRootNode rootNode = context.Instance as IRootNode;
                if (rootNode != null)
                {
                    IBaseNode variables      = rootNode.Tree.RootNode.GetNode(eNodeType.VariableDefinitions);
                    string    domainTemplate = rootNode.DomainTemplate;
                    using (BulkImportForm frm = new BulkImportForm(variables, ucProperties.App, domainTemplate, eImportMode.Template))
                    {
                        if (svc.ShowDialog(frm) == DialogResult.OK)
                        {
                            if (frm.ModelFile != "")
                            {
                                rootNode.Tree.ImportVariables(frm.ImportVariables);
                            }

                            (rootNode as UI_RootNode).Propegate = false;
                            value = frm.ModelFile;
                        }
                    }
                }
            }

            return(value);
        }
コード例 #7
0
        public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context)
        {
            List <string> result = new List <string>();

            result.Add("");

            IBaseNode baseNode = context.Instance as IBaseNode;

            if (baseNode != null)
            {
                List <IBaseNode> nodes = new List <IBaseNode>();
                switch (baseNode.NodeType)
                {
                case eNodeType.Expression:
                    nodes = (baseNode as IExpressionImpl).GetVarObjs(VariableScope);
                    break;

                case eNodeType.Branch:
                    nodes = (baseNode as IBranchImpl).GetVarObjs(VariableScope);
                    break;
                }

                foreach (IBaseNode node in nodes)
                {
                    if (node is IVariableDef)
                    {
                        result.Add(node.Name);
                    }
                }
            }

            return(new StandardValuesCollection(result.ToArray()));
        }
コード例 #8
0
        public virtual void CopyLayoutInfoFrom(IBaseNode baseNode, PointF parentLocation)
        {
            var node = baseNode as IContainerNode;

            if (node == null)
            {
                return;
            }

            // copy location relative to parent
            PointF location = node.Location;

            if (GetParent() != null && node.GetParent() != null)
            {
                location = location.Plus(parentLocation.Minus(node.GetParent().Location));
            }

            Location            = location;
            LocationFixed       = node.LocationFixed;
            Hidden              = node.Hidden;
            IsVisible           = node.IsVisible;
            IsExpanded          = node.IsExpanded;
            IsExpandedByDefault = node.IsExpandedByDefault;
            CopySavedBoundsFrom(node);
        }
コード例 #9
0
        private void OnOnlyAllowSingleSelectStatusChanged(object sender, bool isEnabled)
        {
            // Needed to avoid strange behaviors during the view update
            DisableViewsBehaviors();

            // First save the current selected item to restore it after enable/disable the single select mode
            IBaseNode selectedItem = null;

            if (this.ViewModel?.Folder?.ItemCollection?.OnlyOneSelectedItem == true)
            {
                try { selectedItem = this.ViewModel.Folder.ItemCollection.SelectedItems.First(); }
                catch (Exception ex) { LogService.Log(MLogLevel.LOG_LEVEL_WARNING, "Error saving the only selected item", ex); }
            }

            if (!isEnabled && DeviceService.GetDeviceType() == DeviceFormFactorType.Desktop)
            {
                this.ListView.SelectionMode = ListViewSelectionMode.Extended;
                this.GridView.SelectionMode = ListViewSelectionMode.Extended;
            }
            else
            {
                this.ListView.SelectionMode = ListViewSelectionMode.Single;
                this.GridView.SelectionMode = ListViewSelectionMode.Single;
            }

            // Restore the selected item
            this.ListView.SelectedItem = this.GridView.SelectedItem =
                this.ViewModel.Folder.ItemCollection.FocusedItem = selectedItem;

            // Restore the view behaviors again
            EnableViewsBehaviors();
        }
コード例 #10
0
        public async void TestNodeCrud()
        {
            IBranch branch = await Fixture.Repository.ReadBranchAsync("master");

            JObject nodeObj = new JObject(
                new JProperty("title", "MyNode")
                );
            IBaseNode node = await branch.CreateNodeAsync(nodeObj);

            string expectedRef = "node://" + node.PlatformId + "/" + node.RepositoryId + "/" + node.BranchId + "/" + node.Id;

            Assert.Equal(expectedRef, node.Ref.Ref);

            Assert.NotNull(node.QName);
            Assert.Equal("n:node", node.TypeQName.ToString());

            IBaseNode nodeRead = await branch.ReadNodeAsync(node.Id);

            Assert.Equal(node.Data, nodeRead.Data);

            node.Data["title"] = "New title";
            await node.UpdateAsync();

            await nodeRead.ReloadAsync();

            Assert.Equal(node.Data["title"], nodeRead.Data["title"]);

            await node.DeleteAsync();

            nodeRead = await branch.ReadNodeAsync(node.Id);

            Assert.Null(nodeRead);
        }
コード例 #11
0
ファイル: SharedFoldersPage.xaml.cs プロジェクト: rrsc/uwp
        private void OnMultiSelectDisabled(object sender, EventArgs e)
        {
            // Needed to avoid strange behaviors during the view update
            DisableViewsBehaviors();

            // If there is only one selected item save it to restore it after disable the multi select mode
            IBaseNode selectedItem = null;

            if (this.ViewModel.ActiveView.ItemCollection.OnlyOneSelectedItem)
            {
                selectedItem = this.ViewModel.ActiveView.ItemCollection.SelectedItems.First();
            }

            var listView = this.GetSelectedListView();

            listView.SelectionMode =
                DeviceService.GetDeviceType() == DeviceFormFactorType.Desktop ?
                ListViewSelectionMode.Extended : ListViewSelectionMode.Single;

            // Restore the selected item
            listView.SelectedItem = this.ViewModel.ActiveView.ItemCollection.FocusedItem = selectedItem;

            // Restore the view behaviors again
            EnableViewsBehaviors();
        }
コード例 #12
0
        public async void TestVersions()
        {
            IBranch master = await Fixture.Repository.MasterAsync();

            JObject nodeObj = new JObject(
                new JProperty("title", "Test Node")
                );

            IBaseNode node = await master.CreateNodeAsync(nodeObj);

            string firstChangeset = node.Data.SelectToken("_system.changeset").ToString();

            node.Data["title"] = "new stuff";
            await node.UpdateAsync();

            await node.ReloadAsync();

            Assert.Equal("new stuff", node.Data.GetValue("title").ToString());

            List <IBaseNode> versions = await node.ListVersionsAsync();

            Assert.Equal(2, versions.Count);

            IBaseNode firstVersion = await node.ReadVersionAsync(firstChangeset);

            Assert.Equal("Test Node", firstVersion.Data["title"].ToString());

            IBaseNode restoredVersion = await node.RestoreVersionAsync(firstChangeset);

            Assert.Equal("Test Node", restoredVersion.Data["title"].ToString());
        }
コード例 #13
0
        public async void TestFeatures()
        {
            IBranch branch = await Fixture.Repository.ReadBranchAsync("master");

            IBaseNode node = await branch.CreateNodeAsync(new JObject());

            List <string> featureIds = node.GetFeatureIds();

            Assert.NotEmpty(featureIds);

            JObject filenameObj = new JObject(
                new JProperty("filename", "file1")
                );
            await node.AddFeatureAsync("f:filename", filenameObj);

            featureIds = node.GetFeatureIds();
            Assert.Contains("f:filename", featureIds);
            Assert.True(node.HasFeature("f:filename"));
            JObject featureObj = node.GetFeature("f:filename");

            Assert.Equal("file1", featureObj.GetValue("filename"));

            await node.RemoveFeatureAsync("f:filename");

            featureIds = node.GetFeatureIds();
            Assert.DoesNotContain("f:filename", featureIds);
            Assert.False(node.HasFeature("f:filename"));
            Assert.Null(node.GetFeature("f:filename"));
        }
コード例 #14
0
 public void ExpandParents(IBaseNode baseNode)
 {
     foreach (var parent in baseNode.GetParentNodes())
     {
         parent.IsExpanded = true;
     }
 }
コード例 #15
0
        public ucDataConnectionEditor(IBaseNode node)
        {
            InitializeComponent();

            baseNode      = node;
            lblTitle.Text = node.Name;

            string UserAppFolder = ConfigurationRepository.IConfiguration.GetConfigurationValue("UserAppDataPath", "");

            rootPath = string.Format("{0}{1}-{2}-config.xml", UserAppFolder,
                                     node.Parent.Name.ToLower(),
                                     node.Name.ToLower());

            conf.AddConfigurationSource(
                new IConfigurationSourceImpl("UserAppDataPath", Constants.ConfigurationSource, rootPath));

            string keyId = string.Format("{0}-{1}", node.Parent.Name.ToLower(), node.Name.ToLower());
            IKey   key   = new IKeyImpl(keyId);

            key.keyBytes = KeyUtils.GetBytes(node.Reference.Replace("-", ""));
            conf.IKms.AddKey(key);

            IConfigurationItem item = new IConfigurationItemImpl("secret", "", Constants.ConfigurationSource);

            item.StorageKey = keyId;
            conf.AddConfigurationItem(item);

            string plain = item.GetValue("");

            log.Debug(plain);
        }
コード例 #16
0
        private void RebuildSymbolTree(object fileTag, IBaseNode doxyTree)
        {
            DoxygenNode lastEntity = null;

            if (tvTree.SelectedNode != null)
            {
                lastEntity = tvTree.SelectedNode.Tag as DoxygenNode;
            }

            TreeNode newSelectedNode = null;

            // Find file node from tag
            TreeNode fileNode = FindRootSymbolNode(fileTag);

            Debug.Assert(fileNode != null);

            tvTree.BeginUpdate();
            fileNode.Nodes.Clear();

            if (doxyTree != null)
            {
                List <TreeNode> selNodes = BuildSymbolTree(doxyTree, fileNode, lastEntity);
                if (selNodes.Count == 1)
                {
                    newSelectedNode = selNodes.First();
                }
            }
            tvTree.EndUpdate();

            tvTree.SelectedNode = newSelectedNode;
            if (newSelectedNode != null)
            {
                newSelectedNode.Expand();
            }
        }
コード例 #17
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (svc != null)
            {
                IBaseNode baseNode = context.Instance as IBaseNode;
                using (MethodsFromModelForm frm = new MethodsFromModelForm(baseNode))
                {
                    List <string> Elements = new List <string>();
                    if (value != null)
                    {
                        Elements.AddRange(value as string[]);
                    }

                    frm.Elements = Elements;

                    if (svc.ShowDialog(frm) == DialogResult.OK)
                    {
                        value = frm.Elements.ToArray();
                    }
                }
            }

            return(value);
        }
コード例 #18
0
        private void OnMultiSelectDisabled(object sender, EventArgs e)
        {
            // Set the flag to indicate that the multi select is being disabled
            this.isMultiSelectDisabling = true;

            // Needed to avoid strange behaviors during the view update
            DisableViewsBehaviors();

            // If there is only one selected item save it to restore it after disable the multi select mode
            IBaseNode selectedItem = null;

            if (this.ViewModel.Folder.ItemCollection.OnlyOneSelectedItem)
            {
                selectedItem = this.ViewModel.Folder.ItemCollection.SelectedItems.First();
            }

            if (DeviceService.GetDeviceType() == DeviceFormFactorType.Desktop)
            {
                this.ListView.SelectionMode = ListViewSelectionMode.Extended;
                this.GridView.SelectionMode = ListViewSelectionMode.Extended;
            }
            else
            {
                this.ListView.SelectionMode = ListViewSelectionMode.Single;
                this.GridView.SelectionMode = ListViewSelectionMode.Single;
            }

            // Restore the selected item
            this.ListView.SelectedItem = this.GridView.SelectedItem =
                this.ViewModel.Folder.ItemCollection.FocusedItem = selectedItem;

            // Restore the view behaviors again
            EnableViewsBehaviors();
        }
コード例 #19
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (svc != null)
            {
                IDomainObject domainObject = context.Instance as IDomainObject;
                if (domainObject != null)
                {
                    IBaseNode variables = domainObject.Tree.RootNode.GetNode(eNodeType.VariableDefinitions);
                    string    modelName = (domainObject as IDomainObjectImpl).FullModelName;
                    using (BulkImportForm frm = new BulkImportForm(variables, ucProperties.App, modelName))
                    {
                        if (svc.ShowDialog(frm) == DialogResult.OK)
                        {
                            domainObject.Nodes.Clear();
                            if (frm.ModelFile != "")
                            {
                                foreach (IBaseNode baseNode in frm.ImportVariables)
                                {
                                    domainObject.AddNode(baseNode);
                                }
                            }

                            value = frm.ModelFile;
                        }
                    }
                }
            }

            return(value);
        }
コード例 #20
0
        private void OnOnlyAllowSingleSelectStatusChanged(object sender, bool isEnabled)
        {
            // Needed to avoid strange behaviors during the view update
            DisableViewsBehaviors();

            // First save the current selected item to restore it after enable/disable the single select mode
            IBaseNode selectedItem = null;

            if (this.ViewModel.Folder.ItemCollection.OnlyOneSelectedItem)
            {
                selectedItem = this.ViewModel.Folder.ItemCollection.SelectedItems.First();
            }

            if (!isEnabled && DeviceService.GetDeviceType() == DeviceFormFactorType.Desktop)
            {
                this.ListView.SelectionMode = ListViewSelectionMode.Extended;
                this.GridView.SelectionMode = ListViewSelectionMode.Extended;
            }
            else
            {
                this.ListView.SelectionMode = ListViewSelectionMode.Single;
                this.GridView.SelectionMode = ListViewSelectionMode.Single;
            }

            // Restore the selected item
            this.ListView.SelectedItem = this.GridView.SelectedItem =
                this.ViewModel.Folder.ItemCollection.FocusedItem = selectedItem;

            // Restore the view behaviors again
            EnableViewsBehaviors();
        }
コード例 #21
0
 public MoveDiagramNodeCommand(IMoBiReactionBuildingBlock targetBuildingBlock, string targetNodeName, IBaseNode destinationNode)
     : base(targetBuildingBlock)
 {
     _destinationNode           = destinationNode;
     _destinationParentLocation = destinationNode.GetParent().Location;
     _targetNodeName            = targetNodeName;
 }
コード例 #22
0
        private void OnItemTapped(object sender, TappedRoutedEventArgs e)
        {
            IBaseNode itemTapped = ((FrameworkElement)e.OriginalSource)?.DataContext as IBaseNode;

            if (itemTapped == null)
            {
                return;
            }

            if (DeviceService.GetDeviceType() != DeviceFormFactorType.Desktop && !this.isMultiSelectDisabling)
            {
                this.ViewModel.Folder.OnChildNodeTapped(itemTapped);
                return;
            }

            if (this.isMultiSelectDisabling)
            {
                this.isMultiSelectDisabling = false;
            }

            if (itemTapped is ImageNodeViewModel)
            {
                (itemTapped as ImageNodeViewModel).InViewingRange = true;
            }

            this.ViewModel.Folder.FocusedNode = itemTapped;
        }
コード例 #23
0
ファイル: DiagramModel.cs プロジェクト: Yuri05/OSPSuite.Core
 public void AddNodeId(IBaseNode baseNode)
 {
     if (baseNode != null && !_nodes.Contains(baseNode.Id))
     {
         _nodes.Add(baseNode);
     }
 }
コード例 #24
0
        private void OnRightItemTapped(object sender, RightTappedRoutedEventArgs e)
        {
            if (this.ViewModel.Folder.IsPanelOpen)
            {
                return;
            }

            IBaseNode itemTapped = ((FrameworkElement)e.OriginalSource)?.DataContext as IBaseNode;

            if (itemTapped == null)
            {
                return;
            }

            this.ViewModel.Folder.FocusedNode = itemTapped;

            var view = (ListViewBase)sender;

            if (view == null)
            {
                return;
            }

            if (this.ViewModel.Folder.ItemCollection.IsMultiSelectActive)
            {
                view.SelectedItems.Add(itemTapped);
            }
            else
            {
                view.SelectedItem = itemTapped;
            }
        }
コード例 #25
0
        public BulkImportForm(IBaseNode variables, IApplication app)
        {
            App = app;

            InitializeComponent();
            DestVariables = variables;
        }
コード例 #26
0
        public bool Remove(T item)
        {
            if (Count != 0)
            {
                IBaseNode <T> prev    = null;
                IBaseNode <T> current = Head;

                if (Tail.Data.Equals(item))
                {
                    return(RemoveLast());
                }

                while (current != null)
                {
                    if (current.Data.Equals(item))
                    {
                        if (prev == null)
                        {
                            return(RemoveFirst());
                        }
                        else
                        {
                            prev.Next = current.Next;
                            DecrementIndex();

                            return(true);
                        }
                    }
                    prev    = current;
                    current = current.Next;
                }
            }
            return(false);
        }
コード例 #27
0
 public ImportVariable(IBaseNode dest)
 {
     Destination    = dest;
     _ImageIndex    = 0;
     _ImportAction  = dest == null ? eImportAction.Mine : eImportAction.Theirs;
     _DefaultAction = _ImportAction;
 }
コード例 #28
0
        public void AddBefore(IBaseNode <T> node, T data)
        {
            IBaseNode <T> newNode = new Node <T>(data);

            if (Count != 0)
            {
                IBaseNode <T> prev    = null;
                IBaseNode <T> current = Head;

                while (current != null)
                {
                    if (current.Equals(node))
                    {
                        if (prev == null)
                        {
                            newNode.Next = Head;
                            Head         = newNode;
                            IncrementIndex();
                        }
                        else
                        {
                            prev.Next    = newNode;
                            newNode.Next = current;
                            DecrementIndex();
                        }
                    }
                    prev    = current;
                    current = current.Next;
                }
            }
        }
コード例 #29
0
        private void getLinkProperties(
            IBaseNode node1, IBaseNode node2, object portObject1, object portObject2,
            out ReactionNode reactionNode, out MoleculeNode moleculeNode, out ReactionLinkType reactionLinkType)
        {
            var rNode1 = node1 as ReactionNode;
            var rNode2 = node2 as ReactionNode;

            if (rNode1 == null && rNode2 == null)
            {
                throw new MoBiException(AppConstants.Exceptions.ReactionNodeMissingInLink);
            }

            var mNode1 = node1 as MoleculeNode;
            var mNode2 = node2 as MoleculeNode;

            if (mNode1 == null && mNode2 == null)
            {
                throw new MoBiException(AppConstants.Exceptions.MoleculeNodeMissingInLink);
            }

            if (rNode1 != null)
            {
                reactionNode     = rNode1;
                moleculeNode     = mNode2;
                reactionLinkType = (ReactionLinkType)portObject1;
            }
            else
            {
                reactionNode     = rNode2;
                moleculeNode     = mNode1;
                reactionLinkType = (ReactionLinkType)portObject2;
            }
        }
コード例 #30
0
ファイル: SelectedNodesService.cs プロジェクト: rrsc/uwp
        /// <summary>
        /// Check if a node is in the selected nodes group for move, copy, import or any other action.
        /// </summary>
        /// <param name="node">Node to check if is in the selected node list</param>
        /// <param name="setDisplayMode">Indicates if is needed to set the display mode of the node</param>
        /// <returns>True if is a selected node or false in other case</returns>
        public static bool IsSelectedNode(IBaseNode node, bool setDisplayMode = false)
        {
            if (!(SelectedNodes?.Count > 0))
            {
                return(false);
            }

            var count = SelectedNodes.Count;

            for (int index = 0; index < count; index++)
            {
                var selectedNode = SelectedNodes[index];
                if (node.Base64Handle == selectedNode.Base64Handle)
                {
                    if (setDisplayMode)
                    {
                        //Update the selected nodes list values
                        node.DisplayMode     = NodeDisplayMode.SelectedNode;
                        SelectedNodes[index] = node;
                    }

                    return(true);
                }
            }

            return(false);
        }