/// <summary>
        /// Загрузить классы, реализующие интерфейс
        /// </summary>
        public void GetTypes()
        {
            var t             = typeof(ITool);
            var assemblyTypes = AppDomain.CurrentDomain.GetAssemblies()
                                .SelectMany(typ => typ.GetTypes())
                                .Where(x => t.IsAssignableFrom(x));
            //на всякий случай избавляемся от интерфейсов
            List <Type> toolTypes = new List <Type>();

            foreach (Type type in assemblyTypes)
            {
                if (type.IsInterface || type.IsAbstract)
                {
                    continue;
                }
                else
                {
                    toolTypes.Add(type);
                }
            }
            foreach (Type type in toolTypes)
            {
                ITool plugin = (ITool)Activator.CreateInstance(type);
                ToolList.Add(plugin);
            }
            // Пусть первый инструмент будет выбран по умолчанию!
            ToolList[0].Select();
            SelectedTool = ToolList[0];
        }
Exemple #2
0
        public JsonResult Insert()
        {
            if (Request.Form.Count == 0)
            {
                return(Json(new ReturnToolList(), JsonRequestBehavior.AllowGet));
            }
            ToolList tool = Newtonsoft.Json.JsonConvert.DeserializeObject <ToolList>(Request.Form[0]);
            HttpFileCollectionBase file = Request.Files;

            if (file.Count > 0)
            {
                string[] request = new String[file.Count];
                string   path    = "~/Images/";
                for (int i = 0; i < file.Count; i++)
                {
                    string fileName  = (string)(Path.GetFileName(file[i].FileName)).Split('.')[0];
                    string extension = Path.GetExtension(file[i].FileName);

                    fileName   = fileName + DateTime.Now.ToString("yyMMddHHmmss") + extension;
                    request[i] = path + fileName;
                    fileName   = Path.Combine(Server.MapPath(path), fileName);
                    file[i].SaveAs(fileName);
                }
                tool.ImageUrl = JsonConvert.SerializeObject(request);
            }
            return(Json(toolDB.Insert(tool), JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
    void Update()
    {
        Frame frame = m_controller.Frame();

        // update the pointer controller
        ToolList tools = frame.Tools;

        if (m_pointerController)
        {
            if (tools.Count > 0)
            {
                Tool tool = tools[0];
                // leap motion uses different object for vectors
                Vector3 positionVector = new Vector3(tool.TipPosition.x, tool.TipPosition.y, tool.TipPosition.z);
                m_pointerController.ToolMoved(positionVector);
            }

            // do something with the tracking data in the frame...
            GestureList gestures = frame.Gestures();
            if (gestures.Count > 0)
            {
                foreach (Gesture gesture in gestures)
                {
                    if (gesture.State == Gesture.GestureState.STATESTOP)
                    {
                        m_pointerController.Gesture(gesture);
                        Debug.Log(gesture.Type + " : " + gesture.Duration);
                    }
                }
            }
        }
    }
Exemple #4
0
        public bool SaveTools()
        {
            if (CheckPassTool(PreviouslySelectedIndex))
            {
                // Figure out which tools have been removed and if a directory in the tools folder can be removed.
                // Check if we can delete any toolDirs based on the tools on the remove list.
                if (Removelist.Count > 0)
                {
                    var referencedPaths = ToolList.Where(t => !string.IsNullOrEmpty(t.ToolDirPath))
                                          .Select(t => t.ToolDirPath).ToArray();
                    foreach (var removeTool in Removelist)
                    {
                        if (!string.IsNullOrEmpty(removeTool.ToolDirPath) &&
                            Directory.Exists(removeTool.ToolDirPath) &&
                            !referencedPaths.Contains(removeTool.ToolDirPath))
                        {
                            DirectoryEx.SafeDelete(removeTool.ToolDirPath);
                        }
                    }
                }

                Settings.Default.ToolList = Properties.ToolList.CopyTools(ToolList);
                Unsaved    = false;
                Removelist = new List <ToolDescription>();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        public void AddDialog(string title,
                              string command,
                              string arguments,
                              string initialDirectory,
                              bool isImmediateOutput,
                              string selectedReport,
                              string argsCollectorDllPath,
                              string argsCollectorType,
                              string toolDirPath,
                              string packageVersion,
                              string packageIdentifier,
                              string packageName)
        {
            ToolDescription newTool;

            if (ToolDescription.IsWebPageCommand(command))
            {
                newTool = new ToolDescription(GetTitle(title), command, arguments, string.Empty, false,
                                              selectedReport, argsCollectorDllPath, argsCollectorType, toolDirPath, null, packageVersion, packageIdentifier, packageName);
            }
            else
            {
                newTool = new ToolDescription(GetTitle(title), command, arguments, initialDirectory, isImmediateOutput,
                                              selectedReport, argsCollectorDllPath, argsCollectorType, toolDirPath, null, packageVersion, packageIdentifier, packageName);
            }
            ToolList.Add(newTool);
            RefreshListBox();
            PreviouslySelectedIndex = -1;
            listTools.SelectedIndex = ToolList.Count - 1;
            btnRemove.Enabled       = true;
        }
Exemple #6
0
 /// <summary>
 /// Create new instance of tool for creating lines
 /// </summary>
 /// <returns></returns>
 public Commands.ICommand CreateLineTool()
 {
     _tool = new Tools.LineTool();
     _cmd = new Commands.LineCommand((Tools.LineTool)_tool);
     _lastTool = ToolList.LineTool;
     return _cmd;
 }
        public DataTable toolListToDT(ToolList toolsList)
        {
            DataTable toolListTable = new DataTable();

            foreach (productionColumnsNames header in Enum.GetValues(typeof(productionColumnsNames)))
            {
                toolListTable.Columns.Add(header.ToString());
            }

            foreach (Tool tool in toolsList.toolList)
            {
                DataRow dRow = toolListTable.NewRow();

                dRow[productionColumnsNames.ToolID.ToString()]        = tool.ToolID;
                dRow[productionColumnsNames.ToolName.ToString()]      = tool.ToolName;
                dRow[productionColumnsNames.ToolType.ToString()]      = tool.ToolType.ToString();
                dRow[productionColumnsNames.CurrentStatus.ToString()] = tool.CurrentStatus.ToString();
                if (tool.CurrentProductionOrder != null)
                {
                    dRow[productionColumnsNames.ProductName.ToString()] = tool.CurrentProductionOrder.Product.ProductName;
                    dRow[productionColumnsNames.OrderID.ToString()]     = tool.CurrentProductionOrder.OrderID;
                }
                dRow[productionColumnsNames.TimeRemaining.ToString()] = tool.ProcessingTimeRemaining.ToString();

                toolListTable.Rows.Add(dRow);
            }

            return(toolListTable);
        }
Exemple #8
0
            public override void OnFrame(Controller leap)
            {
                var frame = leap.Frame();

#if true
                // 今回のフレームで検出したすべての手、指、ツール
                HandList      hands      = frame.Hands;
                FingerList    fingers    = frame.Fingers;
                ToolList      tools      = frame.Tools;
                PointableList pointables = frame.Pointables;

                Console.WriteLine(string.Format("手 : {0} 指 : {1} ツール : {2} ポインタ : {3}",
                                                hands.Count, fingers.Count, tools.Count, pointables.Count));
#endif

#if false
                // 手のIDから、同じ手を追跡し続ける
                if (handId == -1)
                {
                    handId = frame.Hands[0].Id;
                }
                else
                {
                    Hand hand = frame.Hand(handId);
                    handId = hand.Id;

                    // 手の情報を表示する
                    Console.WriteLine(string.Format("ID : {0} 位置 : {1} 速度 : {2} 法線 : {3} 向き : {4}",
                                                    hand.Id, hand.PalmPosition, hand.PalmVelocity, hand.PalmNormal, hand.Direction));
                }
#endif

#if false
                // 一番左、右、手前の手を取得する
                HandList hands     = frame.Hands;
                Hand     leftMost  = hands.Leftmost;
                Hand     rightMost = hands.Rightmost;
                Hand     frontMost = hands.Frontmost;

                Console.WriteLine(string.Format("左 : {0} 右 : {1} 手前 : {2}",
                                                leftMost.PalmPosition, rightMost.PalmPosition, frontMost.PalmPosition));
#endif

#if false
                // 手に属している指とツールを取得する
                foreach (var hand in frame.Hands)
                {
                    Console.WriteLine(string.Format("ID : {0} ポインタ : {1} 指: {2} ツール : {3}",
                                                    hand.Id, hand.Pointables.Count, hand.Fingers.Count, hand.Fingers.Count));
                }
#endif

#if false
                // 指の情報を表示する
                Finger finger = frame.Fingers[0];
                Console.WriteLine(string.Format("ID : {0} 位置 : {1} 速度 : {2} 向き : {3}",
                                                finger.Id, finger.TipPosition, finger.TipVelocity, finger.Direction));
#endif
            }
Exemple #9
0
        public ToolSelectForm(Form parent, ToolList list)
            : base(true, parent, list)
        {
            InitializeComponent();
            _view_mode = molView.Select;

            _action_result = DialogResult.Cancel;
        }
 private void FixedUpdate()
 {
     currentFrame = leapMotionController.Frame();
     gestures = currentFrame.Gestures();
     hands = currentFrame.Hands;
     fingers = currentFrame.Fingers;
     tools = currentFrame.Tools;
 }
 public ToolInfoStruct(ToolList newId, ToolTypes newType, int newTier, int newDamage, Dictionary <ResourceList, int> newRecipe)
 {
     id     = newId;
     type   = newType;
     tier   = newTier;
     damage = newDamage;
     recipe = newRecipe;
 }
        public ProductionManager(ToolList toolList, ToolTypeClassList ToolTypeList)
        {
            ToolsList       = toolList;
            ProductionQueue = new Dictionary <ToolTypeClass, ProductionOrderList>();

            foreach (var toolType in ToolTypeList.ToolTypeList)
            {
                ProductionQueue.Add(toolType, new ProductionOrderList());
            }
        }
 public bool UpdateData(ToolList tools)
 {
     try
     {
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Exemple #14
0
        public static void RunTool(ToolList Tools)
        {
            //List<Finger> sortedFingers = Fingers.OrderBy(Finger => Finger.Id).ToList();
            List <Tool> sortedTools = Tools.ToList(); //temp

            if (sortedTools[0].TipPosition.z < Properties.Settings.Default.TouchThreshold)
            {
                isTouching[0] = true;
            }
            else
            {
                isTouching[0] = false;
            }


            if (isTouching[0] == true && Holding[0] == false) // pressed
            {
                JustPressed[0] = true;
                Holding[0]     = true;
            }

            if (isTouching[0] == false && Holding[0] == true) // released
            {
                JustReleased[0] = true;
                Holding[0]      = false;
            }


            if (JustPressed[0])
            {
                JustPressed[0] = false;
                TouchDown(0, 1);
            }

            if (JustReleased[0])
            {
                JustReleased[0] = false;
                Release(0, 1);
            }

            if (Holding[0] == false)
            {
                SetHover(0);
            }

            if (!Holding[0]) // temp for game
            {
                injector[0].PointerInfo.PtPixelLocation.X = (int)(sortedTools[0].TipPosition.x * Properties.Settings.Default.TouchCursorSpeed) + 1000;
                injector[0].PointerInfo.PtPixelLocation.Y = -(int)(sortedTools[0].TipPosition.y * Properties.Settings.Default.TouchCursorSpeed) + 2500; // speed 15: add 2500
            }

            //injector.Length
            bool s = TouchInjector.InjectTouchInput(1, injector);
        }
Exemple #15
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (controller.IsConnected)
        {
            Debug.Log("CONNECTED");

            // wait until Controller.isConnected() evaluates to true
            //...

            Frame         frame      = controller.Frame();
            HandList      hands      = frame.Hands;
            PointableList pointables = frame.Pointables;
            FingerList    fingers    = frame.Fingers;
            ToolList      tools      = frame.Tools;


            //Alden wrote:
            //Gesture gesture = frame.Gestures;

            //for (int g = 0; g < frame.Gestures().Count; g++)
            //{
            //    switch (frame.Gestures()[g].Type)
            //    {
            //        case Gesture.GestureType.TYPE_CIRCLE:
            //            //Handle circle gestures
            //            Debug.Log("CIRCLE");
            //            break;
            //        case Gesture.GestureType.TYPE_KEY_TAP:
            //            //Handle key tap gestures
            //            Debug.Log("KEY TAP");
            //            break;
            //        case Gesture.GestureType.TYPE_SCREEN_TAP:
            //            //Handle screen tap gestures
            //            Debug.Log("SCREEN TAP");
            //            break;
            //        case Gesture.GestureType.TYPE_SWIPE:
            //            //Handle swipe gestures
            //            Debug.Log("SWIPE");
            //            break;
            //        default:
            //            //Handle unrecognized gestures
            //            Debug.Log("UNRECOGNIZED");
            //            break;
            //    }
            //}

            Debug.Log(checkForSwipe());
        }
        else
        {
            Debug.Log("NOT CONNECTED");
        }
    }
Exemple #16
0
        public async Task <ToolList> GetToolList(int type)
        {
            String json_toollist = await _tool_provider.GetToolListAsync(type);

            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ToolList));
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json_toollist));
            ToolList     target = new ToolList();

            target = (ToolList)serializer.ReadObject(stream);

            return(target);
        }
Exemple #17
0
        private static void CopyOldTools(string outerToolsFolderPath, ILongWaitBroker broker)
        {
            //Copy tools to a different folder then Directory.Move if successful.
            string tempOuterToolsFolderPath = string.Concat(outerToolsFolderPath, @"_installing");

            if (Directory.Exists(tempOuterToolsFolderPath))
            {
                DirectoryEx.SafeDelete(tempOuterToolsFolderPath);
                // Not sure this is necessay, but just to be safe
                if (Directory.Exists(tempOuterToolsFolderPath))
                {
                    throw new Exception(Resources.Program_CopyOldTools_Error_copying_external_tools_from_previous_installation);
                }
            }

            // Must create the tools directory to avoid ending up here again next time
            Directory.CreateDirectory(tempOuterToolsFolderPath);

            ToolList  toolList      = Settings.Default.ToolList;
            int       numTools      = toolList.Count;
            const int endValue      = 100;
            int       progressValue = 0;
            // ReSharper disable once UselessBinaryOperation (in case we decide to start at progress>0 for display purposes)
            int increment = (endValue - progressValue) / (numTools + 1);

            foreach (var tool in toolList)
            {
                string toolDirPath = tool.ToolDirPath;
                if (!string.IsNullOrEmpty(toolDirPath) && Directory.Exists(toolDirPath))
                {
                    string foldername = Path.GetFileName(toolDirPath);
                    string newDir     = Path.Combine(outerToolsFolderPath, foldername);
                    string tempNewDir = Path.Combine(tempOuterToolsFolderPath, foldername);
                    if (!Directory.Exists(tempNewDir))
                    {
                        DirectoryEx.DirectoryCopy(toolDirPath, tempNewDir, true);
                    }
                    tool.ToolDirPath          = newDir; // Update the tool to point to its new directory.
                    tool.ArgsCollectorDllPath = tool.ArgsCollectorDllPath.Replace(toolDirPath, newDir);
                }
                if (broker.IsCanceled)
                {
                    // Don't leave around a corrupted directory
                    DirectoryEx.SafeDelete(tempOuterToolsFolderPath);
                    return;
                }

                progressValue       += increment;
                broker.ProgressValue = progressValue;
            }
            Directory.Move(tempOuterToolsFolderPath, outerToolsFolderPath);
            Settings.Default.ToolList = ToolList.CopyTools(toolList);
        }
    void Start()
    {
        Controller controller = new Controller();
        // wait until Controller.isConnected() evaluates to true
        //...

        Frame         frame      = controller.Frame();
        HandList      hands      = frame.Hands;
        PointableList pointables = frame.Pointables;
        FingerList    fingers    = frame.Fingers;
        ToolList      tools      = frame.Tools;
    }
Exemple #19
0
        protected virtual void SelectToolLineAction()
        {
            ToolList list = ToolList.GetList(moleQule.Base.EEstado.Active, false);

            ToolSelectForm form = new ToolSelectForm(this, list);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                ToolInfo item = form.Selected as ToolInfo;
                _entity.Lines.NewItem(_entity, item);
            }
        }
Exemple #20
0
 public bool RemoverTool(string ToolName)
 {
     if (ToolsDic != null)
     {
         if (ToolsDic.ContainsKey(ToolName))
         {
             ToolsDic.Remove(ToolName);
             ToolList.Remove(ToolList.Find(p => p.ToolName == ToolName));
             return(true);
         }
     }
     return(false);
 }
Exemple #21
0
 public bool InsertTool(int index, ITool tool)
 {
     if (ToolsDic != null)
     {
         if (!ToolsDic.ContainsKey(tool.ToolName))
         {
             ToolsDic.Add(tool.ToolName, tool);
             ToolList.Insert(index, tool);
             return(true);
         }
     }
     return(false);
 }
Exemple #22
0
 public bool AddTool(ITool tool)
 {
     if (ToolsDic != null)
     {
         if (!ToolsDic.ContainsKey(tool.ToolName))
         {
             ToolsDic.Add(tool.ToolName, tool);
             ToolList.Add(tool);
             return(true);
         }
     }
     return(false);
 }
Exemple #23
0
        public void testGetToollistFromToolService()
        {
            string output           = @"{""toollist"":[{""toolID"":10,""toolLabel"":""this is a label""}]}";
            var    toolProviderMock = Substitute.For <IToolServiceProvider>();

            toolProviderMock.GetToolListAsync(1).Returns(Task.FromResult(output));

            ToolService target = new ToolService(toolProviderMock);
            ToolList    list   = target.GetToolList(1).Result;

            toolProviderMock.Received().GetToolListAsync(1);
            Assert.AreEqual(1, list.toollist.Count, "List Should have 1 object");
            Assert.AreEqual("this is a label", list.toollist[0].toolLabel, "Tool label is incorrect");
        }
Exemple #24
0
        public override void UpdateList()
        {
            switch (_current_action)
            {
            case molAction.Add:
                if (_entity == null)
                {
                    return;
                }
                List.AddItem(_entity.GetInfo(false));
                if (FilterType == IFilterType.Filter)
                {
                    ToolList listA = ToolList.GetList(_filter_results);
                    listA.AddItem(_entity.GetInfo(false));
                    _filter_results = listA.GetSortedList();
                }
                break;

            case molAction.Edit:
            case molAction.Lock:
            case molAction.Unlock:
                if (_entity == null)
                {
                    return;
                }
                ActiveItem.CopyFrom(_entity);
                break;

            case molAction.Delete:
                if (ActiveItem == null)
                {
                    return;
                }
                List.RemoveItem(ActiveOID);
                if (FilterType == IFilterType.Filter)
                {
                    ToolList listD = ToolList.GetList(_filter_results);
                    listD.RemoveItem(ActiveOID);
                    _filter_results = listD.GetSortedList();
                }
                break;
            }

            RefreshSources();
            if (_entity != null)
            {
                Select(_entity.Oid);
            }
            _entity = null;
        }
Exemple #25
0
        /// <summary>
        /// Remove the currently selected value.
        /// </summary>
        public void Remove()
        {
            int spot = listTools.SelectedIndex;

            if (spot >= Settings.Default.ToolList.Count && !Unsaved)
            {
                //Removing a newly added tool
            }
            else
            {
                Unsaved = true;
            }
            Removelist.Add(ToolList[spot]);
            ToolList.RemoveAt(spot);
            RefreshListBox();
            if (ToolList.Count == 0)
            {
                textTitle.Text                     = string.Empty;
                textCommand.Text                   = string.Empty;
                textArguments.Text                 = string.Empty;
                textInitialDirectory.Text          = string.Empty;
                btnRemove.Enabled                  = false;
                PreviouslySelectedIndex            = -1;
                cbOutputImmediateWindow.CheckState = CheckState.Unchecked;
                comboReport.SelectedItem           = string.Empty;
            }
            // If the removed Index was the last in the list, the selected index is the new last element.
            else if (spot == ToolList.Count)
            {
                // If the removed Index was the last in the list, the selected index is the new last element.
                listTools.SelectedIndex = spot - 1;
            }
            else
            {
                listTools.SelectedIndex = spot;
                //In this case the selected index doesn't actually change so the textBoxes still need to be updated.
                ToolDescription highlighted = ToolList[listTools.SelectedIndex];
                textTitle.Text                     = highlighted.Title;
                textCommand.Text                   = highlighted.Command;
                textArguments.Text                 = highlighted.Arguments;
                textInitialDirectory.Text          = highlighted.InitialDirectory;
                cbOutputImmediateWindow.CheckState = highlighted.OutputToImmediateWindow
                                                   ? CheckState.Checked
                                                   : CheckState.Unchecked;
                comboReport.SelectedItem = ComboContainsTitle(highlighted.ReportTitle)
                               ? highlighted.ReportTitle
                               : string.Empty;
            }
        }
Exemple #26
0
        public ToolMngForm(bool isModal, Form parent, ToolList list)
            : base(isModal, parent, list)
        {
            InitializeComponent();

            SetView(molView.Normal);

            // Parche para poder abrir el formulario en modo diseño y no perder la configuracion de columnas
            DatosLocal_BS    = Datos;
            Tabla.DataSource = DatosLocal_BS;

            SetMainDataGridView(Tabla);
            Datos.DataSource = ToolList.NewList().GetSortedList();
            SortProperty     = OName.DataPropertyName;
        }
Exemple #27
0
        public void getTypesCommandReturnsToolListCorrectly()
        {
            string output           = @"{""toollist"":[{""toolID"":10,""toolLabel"":""this is a label""}]}";
            var    toolProviderMock = Substitute.For <IToolServiceProvider>();

            toolProviderMock.GetToolListAsync(1).Returns(Task.FromResult(output));

            ToolService       toolservice = new ToolService(toolProviderMock);
            ToolList          toollist    = new ToolList();
            ToolListViewModel target      = new ToolListViewModel(toollist, toolservice);

            target.GetToolList.Execute(1);
            Assert.AreEqual(1, target.ToolList.toollist.Count, "Toollist should have 1 element");
            Assert.AreEqual(10, target.ToolList.toollist[0].toolID, "ToolID should be 10");
        }
        private void types_Click(object sender, RoutedEventArgs e)
        {
            if (cts != null)
            {
                cts.Cancel();
            }
            // In this section, the root of the JSON is an object, which
            // we then need to map to or store in an instance of a
            // class we have created.
            String      url     = "http://pmb.neongrit.net/aj/selectJSON.php?type=1";
            WebRequest  request = WebRequest.Create(url);
            WebResponse ws      = request.GetResponse();
            ToolList    myTools = JsonConvert.DeserializeObject <ToolList>(new StreamReader(ws.GetResponseStream()).ReadToEnd());

            tbOutput.Text = String.Format("ID {0} is a {1}", myTools.toollist.First().toolID, myTools.toollist.First().toolLabel);
        }
Exemple #29
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            ToolListView view = new ToolListView();

            ToolList toolList = new ToolList();

            HttpClient          httpClient      = new HttpClient();
            ToolServiceProvider serviceProvider = new ToolServiceProvider(httpClient);
            ToolService         toolService     = new ToolService(serviceProvider);
            ToolListViewModel   viewModel       = new ToolListViewModel(toolList, toolService);

            view.DataContext = viewModel;
            view.Show();
        }
Exemple #30
0
        /// <summary>
        /// Asserts that updates are available or not for the sample tool and nested tool, from a given toollist.
        /// </summary>
        private static void AssertUpdateAvailability(ToolList toolList, bool sampleToolUpdateAvailable, bool nestedToolUpdateAvailable)
        {
            var sampleTool =
                Settings.Default.ToolList.First(description => description.PackageIdentifier.Equals(SAMPLE_TOOL.PackageIdentifier));
            var nestedTools =
                Settings.Default.ToolList.Where(description => description.PackageIdentifier.Equals(NESTED_TOOL_A.PackageIdentifier));

            Assert.IsNotNull(sampleTool);
            Assert.IsNotNull(nestedTools);

            Assert.AreEqual(sampleToolUpdateAvailable, sampleTool.UpdateAvailable);
            foreach (var nestedTool in nestedTools)
            {
                Assert.AreEqual(nestedToolUpdateAvailable, nestedTool.UpdateAvailable);
            }
        }
Exemple #31
0
    /**
     * Updates tools based on tracking data in the specified Leap ToolList object.
     * Active ToolModel instances are updated if the tool they represent is still
     * present in the Leap ToolList; otherwise, the ToolModel is removed. If new
     * Leap Tool objects are present in the Leap ToolList, new ToolModels are
     * created and added to the HandController tool list.
     * @param all_tools The dictionary containing the ToolModels to update.
     * @param leap_tools The list of tools from the a Leap Frame instance.
     * @param model The ToolModel instance to use for new tools.
     */
    protected void UpdateToolModels(Dictionary <int, ToolModel> all_tools,
                                    ToolList leap_tools, ToolModel model)
    {
        List <int> ids_to_check = new List <int>(all_tools.Keys);

        // Go through all the active tools and update them.
        int num_tools = leap_tools.Count;

        for (int h = 0; h < num_tools; ++h)
        {
            Tool leap_tool = leap_tools[h];

            // Only create or update if the tool is enabled.
            if (model)
            {
                ids_to_check.Remove(leap_tool.Id);

                // Create the tool and initialized it if it doesn't exist yet.
                if (!all_tools.ContainsKey(leap_tool.Id))
                {
                    ToolModel new_tool = CreateTool(model);
                    new_tool.SetController(this);
                    new_tool.SetLeapTool(leap_tool);
                    new_tool.InitTool();
                    all_tools[leap_tool.Id] = new_tool;
                }

                // Make sure we update the Leap Tool reference.
                ToolModel tool_model = all_tools[leap_tool.Id];
                tool_model.SetLeapTool(leap_tool);
                tool_model.MirrorZAxis(mirrorZAxis);

                // Set scaling.
                tool_model.transform.localScale = transform.lossyScale;

                tool_model.UpdateTool();
            }
        }

        // Destroy all tools with defunct IDs.
        for (int i = 0; i < ids_to_check.Count; ++i)
        {
            Destroy(all_tools[ids_to_check[i]].gameObject);
            all_tools.Remove(ids_to_check[i]);
        }
    }
Exemple #32
0
        private void ComboBoxChanged(object sender, EventArgs e)
        {
            // Reload datagrid with applied filters
            var toolData = new ToolList();

            LoadDataGrid(toolData.Filter(machineComboBox.Text, typeComboBox.Text, functionComboBox.Text));

            //reload comboboxes
            InitializeComboBox();

            //Check if combobox empty
            CheckComboBoxEmpty(functionComboBox);
            CheckComboBoxEmpty(typeComboBox);

            //Clear searchbox
            SearchBox.Text = "Search Tool...";
        }
Exemple #33
0
        public void verifyNotificationOfToolListChangeOccurs()
        {
            string output           = @"{""toollist"":[{""toolID"":10,""toolLabel"":""this is a label""}]}";
            var    toolProviderMock = Substitute.For <IToolServiceProvider>();

            toolProviderMock.GetToolListAsync(1).Returns(Task.FromResult(output));

            ToolService       toolservice = new ToolService(toolProviderMock);
            ToolList          toollist    = new ToolList();
            ToolListViewModel target      = new ToolListViewModel(toollist, toolservice);

            bool eventWasRaised = false;

            target.PropertyChanged += (sender, e) => eventWasRaised = e.PropertyName == "ToolList";
            target.GetToolList.Execute(1);

            Assert.IsTrue(eventWasRaised, "Event for toollist change should have been raised");
        }
        public void TestUpgradedReportSpecList()
        {
            var toolList = new ToolList();
            toolList.AddDefaults();
            var cleanPersistedViews = new PersistedViews(null, null, toolList);
            for (int oldRevision = 0; oldRevision < 2; oldRevision++)
            {
                var oldReportSpecList = new ReportSpecList {RevisionIndex = oldRevision};
                oldReportSpecList.AddRange(oldReportSpecList.GetDefaults(oldRevision));
                var upgradedPersistedViews = new PersistedViews(oldReportSpecList, null, toolList);
                foreach (var group in new[] {PersistedViews.MainGroup, PersistedViews.ExternalToolsGroup})
                {
                    var cleanViews = cleanPersistedViews.GetViewSpecList(group.Id).ViewSpecs.ToArray();
                    var upgragedViews = upgradedPersistedViews.GetViewSpecList(group.Id).ViewSpecs.ToArray();

                    CollectionAssert.AreEquivalent(cleanViews, upgragedViews,
                        "Upgraded from rev {0} in group {1}", oldRevision, group);
                }
            }
        }
Exemple #35
0
    /**
      * Updates tools based on tracking data in the specified Leap ToolList object.
      * Active ToolModel instances are updated if the tool they represent is still
      * present in the Leap ToolList; otherwise, the ToolModel is removed. If new
      * Leap Tool objects are present in the Leap ToolList, new ToolModels are
      * created and added to the HandController tool list.
      * @param all_tools The dictionary containing the ToolModels to update.
      * @param leap_tools The list of tools from the a Leap Frame instance.
      * @param model The ToolModel instance to use for new tools.
      */
    protected void UpdateToolModels(Dictionary<int, ToolModel> all_tools,
                                  ToolList leap_tools, ToolModel model)
    {
        List<int> ids_to_check = new List<int>(all_tools.Keys);

        // Go through all the active tools and update them.
        int num_tools = leap_tools.Count;
        for (int h = 0; h < num_tools; ++h) {
          Tool leap_tool = leap_tools[h];

          // Only create or update if the tool is enabled.
          if (model) {

        ids_to_check.Remove(leap_tool.Id);

        // Create the tool and initialized it if it doesn't exist yet.
        if (!all_tools.ContainsKey(leap_tool.Id)) {
          ToolModel new_tool = CreateTool(model);
          new_tool.SetController(this);
          new_tool.SetLeapTool(leap_tool);
          new_tool.InitTool();
          all_tools[leap_tool.Id] = new_tool;
        }

        // Make sure we update the Leap Tool reference.
        ToolModel tool_model = all_tools[leap_tool.Id];
        tool_model.SetLeapTool(leap_tool);
        tool_model.MirrorZAxis(mirrorZAxis);

        // Set scaling.
        tool_model.transform.localScale = Vector3.one;

        tool_model.UpdateTool();
          }
        }

        // Destroy all tools with defunct IDs.
        for (int i = 0; i < ids_to_check.Count; ++i) {
          Destroy(all_tools[ids_to_check[i]].gameObject);
          all_tools.Remove(ids_to_check[i]);
        }
    }
Exemple #36
0
 /// <summary>
 /// Construct a new PersistedViews, migrating over the values from the old ViewSpecList 
 /// and ReportSpecList properties.  Views that are in use by an external tool get put in
 /// the External Tools group, and views that are
 /// </summary>
 public PersistedViews(ReportSpecList reportSpecList, ViewSpecList viewSpecList, ToolList toolList)
 {
     var viewItems = new List<ViewSpec>();
     if (null != viewSpecList)
     {
         viewItems.AddRange(viewSpecList.ViewSpecs);
     }
     if (null != reportSpecList)
     {
         RevisionIndex = reportSpecList.RevisionIndex + 1;
         foreach (var newView in ReportSharing.ConvertAll(reportSpecList.Select(reportSpec => new ReportOrViewSpec(reportSpec)),
                     new SrmDocument(SrmSettingsList.GetDefault())))
         {
             if (viewItems.Any(viewSpec => viewSpec.Name == newView.Name))
             {
                 continue;
             }
             viewItems.Add(newView);
         }
     }
     var viewSpecLists = new Dictionary<ViewGroup, Dictionary<string, ViewSpec>>();
     foreach (var viewItem in viewItems)
     {
         ViewGroup group;
         if (toolList.Any(tool => tool.ReportTitle == viewItem.Name))
         {
             group = ExternalToolsGroup;
         }
         else
         {
             group = MainGroup;
         }
         Dictionary<string, ViewSpec> list;
         if (!viewSpecLists.TryGetValue(group, out list))
         {
             list = new Dictionary<string, ViewSpec>();
             viewSpecLists.Add(group, list);
         }
         if (!list.ContainsKey(viewItem.Name))
         {
             list.Add(viewItem.Name, viewItem);
         }
         else
         {
             for (int i = 1;; i++)
             {
                 string name = viewItem.Name + i;
                 if (!list.ContainsKey(name))
                 {
                     list.Add(name, viewItem.SetName(name));
                     break;
                 }
             }
         }
     }
     foreach (var entry in viewSpecLists)
     {
         SetViewSpecList(entry.Key.Id, new ViewSpecList(entry.Value.Values));
     }
     AddDefaults();
 }
        /// <summary>
        /// Asserts that updates are available or not for the sample tool and nested tool, from a given toollist.
        /// </summary>
        private static void AssertUpdateAvailability(ToolList toolList, bool sampleToolUpdateAvailable, bool nestedToolUpdateAvailable)
        {
            var sampleTool =
                 Settings.Default.ToolList.First(description => description.PackageIdentifier.Equals(SAMPLE_TOOL.PackageIdentifier));
            var nestedTools =
                Settings.Default.ToolList.Where(description => description.PackageIdentifier.Equals(NESTED_TOOL_A.PackageIdentifier));

            Assert.IsNotNull(sampleTool);
            Assert.IsNotNull(nestedTools);

            Assert.AreEqual(sampleToolUpdateAvailable, sampleTool.UpdateAvailable);
            foreach (var nestedTool in nestedTools)
            {
                Assert.AreEqual(nestedToolUpdateAvailable, nestedTool.UpdateAvailable);
            }
        }
Exemple #38
0
 public ToolBuilder()
 {
     _tool = new Tools.LineTool();
     _cmd = new Commands.LineCommand((Tools.LineTool)_tool);
     _lastTool = ToolList.LineTool;
 }