예제 #1
0
        private void TestList_MouseMove(object sender, MouseEventArgs e)
        {
            if (flag == 1)
            {
                return;
            }
            // Get the current mouse position
            Point  mousePos = e.GetPosition(null);
            Vector diff     = startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                // Get the dragged ListViewItem
                ListView     listView     = sender as ListView;
                ListViewItem listViewItem = FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource);
                if (listViewItem == null)
                {
                    return;                                 // Abort
                }
                // Find the data behind the ListViewItem
                TestsList item = (TestsList)listView.ItemContainerGenerator.ItemFromContainer(listViewItem);
                if (item == null)
                {
                    return;                                 // Abort
                }
                // Initialize the drag & drop operation
                startIndex = TestList.SelectedIndex;
                DataObject dragData = new DataObject("tests", item);
                DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Copy | DragDropEffects.Move);
            }
        }
예제 #2
0
        private void TestList_Drop(object sender, DragEventArgs e)
        {
            int index = -1;

            if (e.Data.GetDataPresent("tests") && sender == e.Source)
            {
                // Get the drop ListViewItem destination
                ListView     listView     = sender as ListView;
                ListViewItem listViewItem = FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource);
                if (listViewItem == null)
                {
                    // Abort
                    e.Effects = DragDropEffects.None;
                    return;
                }
                // Find the data behind the ListViewItem
                TestsList item = (TestsList)listView.ItemContainerGenerator.ItemFromContainer(listViewItem);
                // Move item into observable collection
                // (this will be automatically reflected to TestList.ItemsSource)
                e.Effects = DragDropEffects.Move;
                index     = Items.IndexOf(item);
                if (startIndex >= 0 && index >= 0)
                {
                    Items.Move(startIndex, index);
                }
                startIndex = -1;
                Message message = new Message();
                Message ids     = new Message();
                for (int i = 0; i < Items.Count; i++)
                {
                    ids.Add(Items.ElementAt <TestsList>(i).ID);
                }
                message.Add(IDPack, JsonConvert.SerializeObject(ids));
                String request = JsonConvert.SerializeObject(message);
                response = server.SendMsg("ChangePositionList", Data.ServiceSel, request);
            }
        }
예제 #3
0
 private void UpdateList()
 {
     Items   = new ObservableCollection <TestsList>();
     message = new Message();
     try
     {
         message.Add(IDPack);
         request  = JsonConvert.SerializeObject(message);
         response = server.SendMsg("GetTestsThisPack", Data.ServiceSel, request);
         message  = JsonConvert.DeserializeObject <Message>(response);
         Message   dep;
         TestsList test;
         for (var i = 0; i < message.args.Count; i += 12)
         {
             test         = new TestsList();
             test.ID      = message.args[i];
             test.NewName = message.args[i + 1];
             if (message.args[i + 2] == "default")
             {
                 test.Time = "По умолчанию";
             }
             else
             {
                 test.Time = message.args[i + 2];
             }
             if (message.args[i + 3] == "default")
             {
                 test.Restart = "По умолчанию";
             }
             else
             {
                 test.Restart = message.args[i + 3];
             }
             if (message.args[i + 4] == "default")
             {
                 test.Browser = "По умолчанию";
             }
             else
             {
                 test.Browser = message.args[i + 4];
             }
             if (message.args[i + 6] == "not")
             {
                 test.Duplicatebtn = "Visible";
                 test.DuplicateImg = "/DashBoardClient;component/Images/note_add.png";
             }
             else
             {
                 test.Duplicatebtn = "Visible";
                 test.DuplicateImg = "/DashBoardClient;component/Images/note_delete.png";
             }
             dep = JsonConvert.DeserializeObject <Message>(message.args[i + 5]);
             if (dep.args[0].Equals("not"))
             {
                 test.Dependon = "Нет зависимостей";
                 test.Image    = "/DashBoardClient;component/Images/open.png";
                 test.Func     = "add";
             }
             else
             {
                 dep.args.ForEach(elem => test.Dependon = test.Dependon + elem + "\n");
                 test.Dependon = test.Dependon.Trim();
                 test.Image    = "/DashBoardClient;component/Images/sver.png";
                 test.Func     = "remove";
             }
             Items.Add(test);
         }
     }
     catch { MessageBox.Show("Произошла ошибка! Обратитесь к поддержке!"); }
 }