/// <summary>
 /// owner is a designer class for a custom interface
 /// </summary>
 /// <param name="owner"></param>
 public InterfacePointer(ClassPointer owner)
     : base(owner)
 {
     if (owner == null)
     {
         throw new DesignerException("owner as ClassPointer is null for InterfacePointer constructor");
     }
     _owner   = owner.Interface;
     _classId = owner.ClassId;
 }
Exemple #2
0
 public IOUSBFindInterfaceRequest(InterfaceClass interfaceClass       = (InterfaceClass)DontCare,
                                  InterfaceSubClass interfaceSubClass = (InterfaceSubClass)DontCare,
                                  InterfaceProtocol interfaceProtocol = (InterfaceProtocol)DontCare,
                                  ushort alternateSetting             = DontCare)
 {
     this.interfaceClass    = interfaceClass;
     this.interfaceSubClass = interfaceSubClass;
     this.interfaceProtocol = interfaceProtocol;
     this.alternateSetting  = alternateSetting;
 }
 public InterfacePointer(InterfaceClass owner)
 {
     if (owner == null)
     {
         throw new DesignerException("owner as InterfaceClass is null for InterfacePointer constructor");
     }
     _owner   = owner;
     _classId = _owner.ClassId;
     SetInterfaceClass();
 }
        public List <InterfaceElementProperty> GetProperties()
        {
            ClassPointer cp = this.ClassTypePointer;

            if (cp != null)
            {
                if (!cp.IsInterface)
                {
                    throw new DesignerException("Invalid interface pointer. Class Id:{0}", cp.ClassId);
                }
                if (cp.ObjectInstance == null)
                {
                    throw new DesignerException("Interface object not loaded. Class Id:{0}", cp.ClassId);
                }
                InterfaceClass ifc = VPLUtil.GetObject(cp.ObjectInstance) as InterfaceClass;
                if (ifc == null)
                {
                    throw new DesignerException("Invalid interface pointer. object:{0}", cp.ObjectInstance);
                }
                return(ifc.Properties);
            }
            else
            {
                Type t = this.VariableLibType;
                if (t == null)
                {
                    throw new DesignerException("Invalid interface pointer. VariableLibType is null.");
                }
                if (t.IsInterface)
                {
                    List <InterfaceElementProperty> ls = new List <InterfaceElementProperty>();
                    PropertyInfo[] mifs = VPLUtil.GetProperties(t);
                    if (mifs != null && mifs.Length > 0)
                    {
                        for (int i = 0; i < mifs.Length; i++)
                        {
                            if (!mifs[i].IsSpecialName)
                            {
                                InterfaceElementProperty em = new InterfaceElementProperty(this, mifs[i]);
                                ls.Add(em);
                            }
                        }
                    }
                    return(ls);
                }
                else
                {
                    throw new DesignerException("Invalid interface pointer. Type is not an interface:{0}.", t);
                }
            }
        }
        /*unsafe static void UnsafeCodeConcepts()
         * {
         #region char and pointer concept
         *  MyHelper.PrintHeaderMessage("char and pointer concept");
         *  int* point;
         *  int ch = 13 * 5;
         *  point = &(ch);
         *  Console.WriteLine(Convert.ToChar(*point));
         *  if (*point == 'A')
         *      Console.WriteLine(Convert.ToBoolean(1));
         *  else
         *      Console.WriteLine(Convert.ToBoolean(0));
         *  MyHelper.PrintNoteConcept();
         #endregion
         *
         #region Index pointer like array
         *  MyHelper.PrintHeaderMessage("Index pointer like array");
         *  int[] intArray = new int[10];
         *  fixed (int* p = intArray)
         *  {
         *      for (int i = 0; i < 10; i++)
         *          p[i] = i;
         *      for (int i = 10; i > 0; i--)
         *          Console.WriteLine("p[{0}]: {1} ", i, p[i]);
         *      Console.ReadLine();
         *  }
         *  MyHelper.PrintNoteConcept();
         #endregion
         *
         #region Pointer Address
         *  MyHelper.PrintHeaderMessage("Pointer Address");
         *  int[] nums = new int[10];
         *  fixed (int* p = &nums[0], p2 = nums)
         *  {
         *      if (p == p2)
         *          Console.WriteLine("p and p2 point to same address.");
         *      Console.ReadLine();
         *  }
         *  char[] arr = { 'a', 'b', 'c', 'd', 'e' };
         *  fixed (char* p = arr)
         *  {
         *      int i;
         *      for (i = 0; i < 5; i++)
         *          if (*p % 2 == 0)
         ++*p;
         *          else
         *              (*p)++;
         *      Console.WriteLine(arr);
         *  }
         *  MyHelper.PrintNoteConcept();
         #endregion
         *  MyHelper.PrintEndMessage();
         * }*/
        #endregion

        #region Interface Property Concepts
        static void InterfacePropertyConcept()
        {
            IMyFirstInterface  obj1 = new InterfaceClass();
            IMySecondInterface obj2 = new InterfaceClass();
            InterfaceClass     obj3 = new InterfaceClass();

            //obj1.MyValue = 1;
            obj2.MyValue = 2;
            obj3.MyValue = 3;

            Console.WriteLine(obj1.MyValue);
            //Console.WriteLine(obj2.MyValue);
            Console.WriteLine(obj3.MyValue);
            MyHelper.PrintPointsToRememberMessage();
            Console.WriteLine("1. We cannot set or get the properties value for an object if its undefined");
            MyHelper.PrintNoteConcept();
            MyHelper.PrintEndMessage();
        }
Exemple #6
0
 public void Init()
 {
     try
     {
         ResultPojo result = InterfaceClass.Instance().yyService.mzValidSche(ConfigConstants.ZDBH, ConfigConstants.JYDM, 0);
         if (result != null && result.appCode == "0")
         {
             if (!string.IsNullOrEmpty(result.resultList.ToString()))
             {
             }
         }
         else
         {
             Console.WriteLine(result.dataBuffer);
         }
     }
     catch (Exception ex)
     {
     }
 }
 public void OnBaseInterfaceAdded(InterfaceClass owner, InterfacePointer baseInterface)
 {
     _objExplorer.OnBaseInterfaceAdded(owner, baseInterface);
 }
Exemple #8
0
		public IOUSBFindInterfaceRequest (InterfaceClass interfaceClass = (InterfaceClass)DontCare,
		                                  InterfaceSubClass interfaceSubClass = (InterfaceSubClass)DontCare,
		                                  InterfaceProtocol interfaceProtocol = (InterfaceProtocol)DontCare,
		                                  ushort alternateSetting = DontCare)
		{
			this.interfaceClass = interfaceClass;
			this.interfaceSubClass = interfaceSubClass;
			this.interfaceProtocol = interfaceProtocol;
			this.alternateSetting = alternateSetting;
		}
Exemple #9
0
 public void OnBaseInterfaceAdded(InterfaceClass owner, InterfacePointer baseInterface)
 {
 }
        void listView_Drop(object sender, DragEventArgs e)
        {
            if (this.ItemUnderDragCursor != null)
            {
                this.ItemUnderDragCursor = null;
            }

            e.Effects = DragDropEffects.Move;

            if (!e.Data.GetDataPresent(typeof(ItemType)))
            {
                return;
            }

            // Get the data object which was dropped.
            ItemType data = e.Data.GetData(typeof(ItemType)) as ItemType;

            if (data == null)
            {
                return;
            }

            // Get the ObservableCollection<ItemType> which contains the dropped data object.
            ObservableCollection <ItemType> itemsDestination = this.listViewDestination.ItemsSource as ObservableCollection <ItemType>;

            if (itemsDestination == null)
            {
                throw new Exception(
                          "A ListView managed by ListViewDragManager must have its ItemsSource set to an ObservableCollection<ItemType>.");
            }

            int oldIndex = itemsDestination.IndexOf(data);
            int newIndex = this.IndexUnderDragCursor;

            if (newIndex < 0)
            {
                // The drag started somewhere else, and our ListView is empty
                // so make the new item the first in the list.
                if (itemsDestination.Count == 0)
                {
                    newIndex = 0;
                }

                // The drag started somewhere else, but our ListView has items
                // so make the new item the last in the list.
                else if (oldIndex < 0)
                {
                    newIndex = itemsDestination.Count;
                }

                // The user is trying to drop an item from our ListView into
                // our ListView, but the mouse is not over an item, so don't
                // let them drop it.
                else
                {
                    return;
                }
            }

            // Dropping an item back onto itself is not considered an actual 'drop'.
            if (oldIndex == newIndex)
            {
                return;
            }

            if (this.ProcessDrop != null)
            {
                // Let the client code process the drop.
                ProcessDropEventArgs <ItemType> args = new ProcessDropEventArgs <ItemType>(itemsDestination, data, oldIndex, newIndex, e.AllowedEffects);
                this.ProcessDrop(this, args);
                e.Effects = args.Effects;
            }
            else
            {
                foreach (ListView lv in allListViews)
                {
                    ObservableCollection <InterfaceClass> itemsSource = lv.ItemsSource as ObservableCollection <InterfaceClass>;
                    InterfaceClass obj = null;
                    if (itemsSource != null)
                    {
                        foreach (InterfaceClass item in itemsSource)
                        {
                            obj = data as InterfaceClass;
                            if (item.Addres.Equals(obj.Addres))
                            {
                                break;
                            }
                        }
                    }
                    if (obj != null && itemsSource != null)
                    {
                        itemsSource.Remove(obj);
                    }
                }
                foreach (ListView lv in allListViews)
                {
                    ObservableCollection <FileExtensionClass> itemsSource = lv.ItemsSource as ObservableCollection <FileExtensionClass>;
                    FileExtensionClass obj = null;
                    if (itemsSource != null)
                    {
                        foreach (FileExtensionClass item in itemsSource)
                        {
                            obj = data as FileExtensionClass;
                            if (item.Extension.Equals(obj.Extension))
                            {
                                break;
                            }
                        }
                    }
                    if (obj != null && itemsSource != null)
                    {
                        itemsSource.Remove(obj);
                    }
                }

                itemsDestination.Insert(newIndex, data);

                // Set the Effects property so that the call to DoDragDrop will return 'Move'.
                e.Effects = DragDropEffects.Move;
            }
        }