Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 private void SetFunction(SequenceFunction func_)
 {
     m_Function = func_;
     m_Function.PropertyChanged     += new System.ComponentModel.PropertyChangedEventHandler(OnFuntionPropertyChanged);
     m_Function.FunctionSlotChanged += new EventHandler <FunctionSlotChangedEventArg>(OnFunctionSlotChanged);
     UpdateNodeSlot();
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateFunction_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            SequenceParametersWindow win = new SequenceParametersWindow();

            win.Title                    = "New Function parameters";
            win.InputName                = "name of the function";
            win.InputDescription         = "";
            win.IsValidInputNameCallback = GraphDataManager.Instance.IsValidFunctionName;
            win.Owner                    = MainWindow.Instance;

            if (win.ShowDialog() == false)
            {
                return;
            }

            SequenceFunction newSeq = new SequenceFunction(win.InputName);

            newSeq.Description = win.InputDescription;
            GraphDataManager.Instance.AddFunction(newSeq);

            FlowGraphControlViewModel wm = new FlowGraphControlViewModel(newSeq);

            wm.InitialNodeFromNewFunction();
            FlowGraphManager.Instance.Add(wm);

            MainWindow.Instance.FlowGraphManagerControl.OpenGraphInNewTab(newSeq);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBoxGraphFunctions_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (m_IsDragAndDrop == true)
            {
                // Get the current mouse position
                Point  mousePos = e.GetPosition(null);
                Vector diff     = m_DragStartPoint - mousePos;

                if (e.LeftButton == MouseButtonState.Pressed &&
                    sender is ListBox &&
                    e.OriginalSource is DependencyObject &&
                    (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                     Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
                {
                    ListBox     listBox     = sender as ListBox;
                    ListBoxItem listBoxItem =
                        Helper.FindAnchestor <ListBoxItem>((DependencyObject)e.OriginalSource);

                    if (listBoxItem != null)
                    {
                        SequenceFunction func = (SequenceFunction)listBox.ItemContainerGenerator.
                                                ItemFromContainer(listBoxItem);

                        if (func != null)
                        {
                            DataObject dragData = new DataObject(DataFormats.Text, DragPrefixFunction + func.Id.ToString());
                            DragDrop.DoDragDrop(listBoxItem, dragData, DragDropEffects.Move);
                        }
                    }
                }
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonAddOutput_Click(object sender, RoutedEventArgs e)
 {
     if (DataContext is SequenceFunction)
     {
         SequenceFunction func = DataContext as SequenceFunction;
         func.AddOutput("output");
     }
     else if (DataContext is ScriptElement)
     {
         ScriptElement el = DataContext as ScriptElement;
         el.AddOutput("output");
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteSlot_Click(object sender, MouseButtonEventArgs e)
        {
            if (sender is Image)
            {
                Image img = sender as Image;

                if (img.Tag is int)
                {
                    int id = (int)img.Tag;

                    if (DataContext is SequenceFunction)
                    {
                        SequenceFunction func = DataContext as SequenceFunction;
                        func.RemoveSlotById(id);
                    }
                    else if (DataContext is ScriptElement)
                    {
                        ScriptElement el = DataContext as ScriptElement;
                        el.RemoveSlotById(id);
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DropList_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                try
                {
                    string data = e.Data.GetData(DataFormats.StringFormat) as string;

                    if (data.StartsWith(FlowGraphDataControl.DragPrefixFunction) == true)
                    {
                        string           id      = data.Split('#')[1];
                        SequenceFunction func    = GraphDataManager.Instance.GetFunctionByID(int.Parse(id));
                        CallFunctionNode seqNode = new CallFunctionNode(func);
                        ViewModel.CreateNode(seqNode, e.GetPosition(networkControl), false);
                    }
                    else if (data.StartsWith(FlowGraphDataControl.DragPrefixNamedVar) == true)
                    {
                        string            name    = data.Split('#')[1];
                        NamedVariableNode seqNode = new NamedVariableNode(name);
                        ViewModel.CreateNode(seqNode, e.GetPosition(networkControl), false);
                    }
                    else if (data.StartsWith(FlowGraphDataControl.DragPrefixScriptElement) == true)
                    {
                        string        idStr   = data.Split('#')[1];
                        int           id      = int.Parse(idStr);
                        ScriptElement el      = GraphDataManager.Instance.GetScriptByID(id);
                        ScriptNode    seqNode = new ScriptNode(el);
                        ViewModel.CreateNode(seqNode, e.GetPosition(networkControl), false);
                    }
                }
                catch (System.Exception ex)
                {
                    LogManager.Instance.WriteException(ex);
                }
            }
        }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="node_"></param>
 public OnEnterFunctionEvent(SequenceFunction func_)
     : base()
 {
     m_Function = func_;
     m_Function.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnFuntionPropertyChanged);
 }
Beispiel #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="functionID_"></param>
 public ReturnNode(SequenceFunction function_)
     : base()
 {
     m_Function = function_;
     m_Function.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnFuntionPropertyChanged);
 }
Beispiel #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="functionID_"></param>
 public ReturnNode(SequenceFunction function_)
     : base()
 {
     m_Function = function_;
     m_Function.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnFuntionPropertyChanged);
 }
Beispiel #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 private void SetFunction(SequenceFunction func_)
 {
     m_Function = func_;
     m_Function.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnFuntionPropertyChanged);
     m_Function.FunctionSlotChanged += new EventHandler<FunctionSlotChangedEventArg>(OnFunctionSlotChanged);
     UpdateNodeSlot();
 }
        private int m_FunctionID = -1; // used when the node is loaded, in order to retrieve the function

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="node_"></param>
        public OnEnterFunctionEvent(SequenceFunction func_)
            : base()
        {
            m_Function = func_;
            m_Function.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnFuntionPropertyChanged);
        }
Beispiel #12
0
        private int m_FunctionID = -1; // used when the node is loaded, in order to retrieve the function

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="functionID_"></param>
        public CallFunctionNode(SequenceFunction function_)
            : base()
        {
            SetFunction(function_);
        }
Beispiel #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="functionID_"></param>
 public CallFunctionNode(SequenceFunction function_)
     : base()
 {
     SetFunction(function_);
 }