Beispiel #1
0
 private void unselectAll_()
 {
     previewTranCon_.Reset();
     TaskTable.Clear();
     taskElemsToRows_.Clear();
     rowsToTasks_.Clear();
 }
        public void clearContext()
        {
            addin_.SelectionChangedEvent -= Addin_SelectionChangedEvent;
            previewTranCon_?.Reset();
            selectionTranCon_?.Reset();

            taskElemsToRows_.Clear();
            TaskTable.Clear();
            OnPropertyChanged(NP.TaskSelection);
        }
        private void Addin_SelectionChangedEvent(
            AddIn sender, AddIn.SelectionChangedEventArgs eventArgs)
        {
            try
            {
                if (eventArgs.Action == lastSelectionAction_ &&
                    eventArgs.FilePosition == lastFilePos_)
                {
                    return;
                }

                switch (eventArgs.Action)
                {
                case AddIn.SelectionChangedEventArgs.ActionKind.SetEmpty:
                    previewTranCon_.Reset();
                    TaskTable.Clear();
                    taskElemsToRows_.Clear();
                    rowsToTasks_.Clear();
                    break;

                case AddIn.SelectionChangedEventArgs.ActionKind.Remove:
                {
                    Element element = ElementHelper.getElement(eventArgs);
                    if (taskElemsToRows_.ContainsKey(element))
                    {
                        DataRow row = taskElemsToRows_[element];
                        rowsToTasks_.Remove(row);
                        TaskTable.Rows.Remove(row);
                        taskElemsToRows_.Remove(element);
                    }
                    break;
                }

                case AddIn.SelectionChangedEventArgs.ActionKind.New:
                {
                    Element element = ElementHelper.getElement(eventArgs);

                    OpeningTask task;
                    if (OpeningHelper.getFromElement(element, AttrsXDoc, out task) &&
                        !taskElemsToRows_.ContainsKey(element))
                    {
                        DataRow row = TaskTable.Rows.Add();

                        row.SetField(FieldName.HEIGHT, task.Height);
                        row.SetField(FieldName.WIDTH, task.Width);
                        row.SetField(FieldName.DEPTH, task.Depth);

                        foreach (var pair in task.DataGroupPropsValues)
                        {
                            Sp3dToDataGroupMapProperty dgProp = pair.Key;
                            if (dgProp.Key == FieldName.CODE)
                            {
                                row.SetField(FieldName.CODE, pair.Value);
                            }
                            else if (TaskTable.Columns.Contains(dgProp.TargetName))
                            {
                                row.SetField(dgProp.TargetName, pair.Value);
                            }
                        }

                        taskElemsToRows_.Add(element, row);
                        rowsToTasks_.Add(row, task);
                    }
                    break;
                }

                case AddIn.SelectionChangedEventArgs.ActionKind.SetChanged:
                {
                    if (lastSelectionAction_ !=
                        AddIn.SelectionChangedEventArgs.ActionKind.New)
                    {
                        break;
                    }

                    //TaskSelection.RaiseListChangedEvents = false;
                    //foreach (PenetrVueTask task in tasksBuf_.Values)
                    //{
                    //    //Logger.Log.Info($"Выбор объекта заадния {task.ToString()}");
                    //    TaskSelection.Add(task);
                    //}
                    //tasksBuf_.Clear();
                    //TaskSelection.RaiseListChangedEvents = true;
                    break;
                }
                }

                //TaskSelection.ResetBindings();
                OnPropertyChanged(NP.TaskSelection);
            }
            catch (Exception ex)
            {
                // todo обработать
                ex.AddToMessageCenter();
            }
            finally
            {
                lastSelectionAction_ = eventArgs.Action;
                lastFilePos_         = eventArgs.FilePosition;
            }
        }