Пример #1
0
        public IVisibleObject DoTransformation(IVisibleObject obj)
        {
            try
            {
                if (obj.Value is string tmp && tmp.Length > 0)
                {
                    tmp = tmp.ToLower();
                    if (tmp.Length % 2 != 0)
                    {
                        return(null);
                    }

                    List <byte> buff = new List <byte>();
                    for (int i = 0; i < tmp.Length; i += 2)
                    {
                        int c1 = Characters.IndexOf(tmp[i]);
                        int c2 = Characters.IndexOf(tmp[i + 1]);
                        if (c1 < 0 || c2 < 0)
                        {
                            return(null);
                        }
                        int v = (c1 << 4) + c2;
                        buff.Add(System.Convert.ToByte(v));
                    }

                    return(new ByteArrayVisibleObject(buff.ToArray(), obj, this));
                }
            }
            catch (Exception)
            {
                // INFO: intentionally left blank
            }
            return(null);
        }
Пример #2
0
 public IVisibleObject DoTransformation(IVisibleObject obj)
 {
     try
     {
         if (obj.Value is string)
         {
             return(new Uint16VisibleObject(ushort.Parse(obj.Value as string, NumberStyles.HexNumber, null), obj, this));
         }
         else if (obj.Value is byte[])
         {
             byte[] tmp = obj.Value as byte[];
             if (tmp.Length != 2)
             {
                 return(null);
             }
             ushort val = System.Convert.ToUInt16((tmp[0] << 8) + tmp[1]);
             return(new Uint16VisibleObject(val, obj, this));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Пример #3
0
 public IVisibleObject DoTransformation(IVisibleObject obj)
 {
     try
     {
         if (obj.Value is string tmp)
         {
             StringBuilder sb      = new StringBuilder();
             int           counter = 0;
             foreach (var c in tmp)
             {
                 if (Characters.IndexOf(c) < 0)
                 {
                     counter++;
                     continue;
                 }
                 sb.Append(c);
             }
             if (counter > 0)
             {
                 // only if some some characters were filtered out
                 string result = sb.ToString();
                 if (!string.IsNullOrEmpty(result))
                 {
                     return(new StringVisibleObject(sb.ToString(), obj, this));
                 }
             }
         }
     }
     catch (Exception)
     {
         // INFO: intentionally left blank
     }
     return(null);
 }
Пример #4
0
        public IVisibleObject DoTransformation(IVisibleObject obj)
        {
            try
            {
                byte[] buff;
                switch (obj.Value)
                {
                case ushort tmp1:
                    buff = new byte[] { (byte)((tmp1 >> 8) & 0x00ff), (byte)(tmp1 & 0x00ff) };
                    break;

                case uint tmp2:
                    buff = new byte[] { (byte)((tmp2 >> 24) & 0x00ff), (byte)((tmp2 >> 16) & 0x00ff), (byte)((tmp2 >> 8) & 0x00ff), (byte)(tmp2 & 0x00ff) };
                    break;

                default:
                    return(null);
                }

                return(new StringVisibleObject(RenderBinaryString(buff), obj, this, true));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #5
0
 public NodeEditorNodes(EditorWindow _editorWindow,
                        NodeConfig _nodeConfig,
                        ConstellationScript _constellationScript,
                        IUndoable _undoable,
                        NodeEditorSelection _nodeEditorSelection,
                        ILinkEditor _linkEditor,
                        IGUI _gui,
                        IVisibleObject _visibleObject,
                        NodeAdded _nodeAdded,
                        NodeRemoved _nodeRemoved,
                        HelpClicked _helpClicked)
 {
     linkEditor          = _linkEditor;
     editorWindow        = _editorWindow;
     Nodes               = new List <NodeView> ();
     nodeConfig          = _nodeConfig;
     constellationScript = _constellationScript;
     isInstance          = constellationScript.IsInstance;
     nodesFactory        = new NodesFactory();
     undoable            = _undoable;
     nodeEditorSelection = _nodeEditorSelection;
     GUI            = _gui;
     visibleObject  = _visibleObject;
     OnNodeAdded   += _nodeAdded;
     OnNodeRemoved += _nodeRemoved;
     OnHelpClicked += _helpClicked;
     SetNodes();
 }
Пример #6
0
 public IVisibleObject DoTransformation(IVisibleObject obj)
 {
     if (obj.Value is ushort @ushort)
     {
         return(new VisibleObject(new StatusWord(@ushort, _map[@ushort]), obj, this, true));
     }
     return(null);
 }
Пример #7
0
        private void BuildTree(IEnumerable <IVisibleObject> results, IVisibleObject root)
        {
            IEnumerable <IVisibleObject> roots = results.Where(v => v.Parent == root);

            foreach (var r in roots)
            {
                Transformation node = new Transformation(r);
                Children.Add(node);

                BuildSubTree(results, node);
            }
        }
Пример #8
0
        private string GetPath(IVisibleObject vo)
        {
            if (vo == null)
            {
                return(null);
            }
            string prev = "";

            if (vo.Parent != null)
            {
                string parent = GetPath(vo.Parent);
                prev = string.IsNullOrEmpty(parent) ? "" : parent + " / ";
            }
            return(prev + (vo.Transformation != null ? vo.Transformation.Name : ""));
        }
Пример #9
0
 public IVisibleObject DoTransformation(IVisibleObject obj)
 {
     try
     {
         string tmpStr = obj.Value as string;
         if (!string.IsNullOrEmpty(tmpStr))
         {
             return(new ByteArrayVisibleObject(System.Convert.FromBase64String(tmpStr), obj, this));
         }
         if (obj.Value is byte[] tmpBt && tmpBt.Length > 0)
         {
             return(new StringVisibleObject(System.Convert.ToBase64String(tmpBt), obj, this));
         }
     }
     catch (Exception)
     {
         // INFO: intentionally left blank
     }
     return(null);
 }
Пример #10
0
        public NodeView(NodeData _node, IVisibleObject _visibleObject, NodeConfig _nodeConfig, ConstellationScript _constellation, ILinkEditor _linkEditor)
        {
            nodeConfig = _nodeConfig;
            var nodeWidth = nodeConfig.NodeWidth;

            if (_node.GetAttributes().Length > 0)
            {
                nodeWidth = nodeConfig.NodeWidthAsAttributes;
            }
            Rect                = new Rect(_node.XPosition, _node.YPosition, nodeWidth, (Mathf.Max(Mathf.Max(_node.Inputs.Count, _node.Outputs.Count), _node.AttributesData.Count) * nodeConfig.InputSize) + nodeConfig.TopMargin);
            node                = _node;
            visibleObject       = _visibleObject;
            constellationScript = _constellation;
            linkEditor          = _linkEditor;


            foreach (var attribute in node.AttributesData)
            {
                attribute.Value = AttributeStyleFactory.Reset(attribute.Type, attribute.Value);
            }
        }
Пример #11
0
 public Uint16VisibleObject(ushort val, IVisibleObject parent = null, ITransformation transformation = null, bool final = false)
     : base(parent, transformation, final)
 {
     _val = val;
 }
Пример #12
0
 public Transformation(IVisibleObject vo)
 {
     _vo      = vo;
     Children = new TransformationCollection();
 }
Пример #13
0
 public bool IsChild(IVisibleObject obj)
 {
     return(_vo == obj.Parent);
 }
Пример #14
0
 public bool IsParent(IVisibleObject obj)
 {
     return(_vo.Parent == obj);
 }
Пример #15
0
 public Transformation(IEnumerable <IVisibleObject> results, IVisibleObject root) : this(root)
 {
     BuildTree(results, root);
 }
Пример #16
0
 public StringVisibleObject(string str, IVisibleObject parent = null, ITransformation transformation = null, bool final = false)
     : base(parent, transformation, final)
 {
     _val = str;
 }
Пример #17
0
 public ByteArrayVisibleObject(byte[] arr, IVisibleObject parent = null, ITransformation transformation = null, bool final = false)
     : base(parent, transformation, final)
 {
     _val = arr;
 }