Пример #1
0
        void AddNew(SimpleObject newObj)
        {
            SettingsDesignerItemViewModel box = new SettingsDesignerItemViewModel();

            box.Parent = window1ViewModel.DiagramViewModel;
            box.Left   = start;
            box.Top    = start + step * raws++;
            box.Id     = newObj.Id;
            window1ViewModel.DiagramViewModel.Items.Add(box);
        }
Пример #2
0
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            simpleCollection = new SimpleCollection(objectsPath, linksPath, true);

            int tric = (int)Math.Sqrt(simpleCollection.Objects.Count);
            int x = -1, y = 0;

            foreach (SimpleObject obj in simpleCollection.Objects)
            {
                SettingsDesignerItemViewModel box = new SettingsDesignerItemViewModel();
                box.Parent = window1ViewModel.DiagramViewModel;
                box.Left   = start + step * ++x;
                box.Top    = start + step * y;
                if (x >= tric)
                {
                    x = -1; y++; raws++;
                }
                box.Id = obj.Id;
                window1ViewModel.DiagramViewModel.Items.Add(box);
            }
            foreach (SimpleLink link in simpleCollection.Links)
            {
                SettingsDesignerItemViewModel firstObj  = null;
                SettingsDesignerItemViewModel secondObj = null;
                try
                {
                    firstObj  = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(f => f.Id == link.Start);
                    secondObj = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(s => s.Id == link.End);
                }
                catch (Exception)
                {
                    continue; //:)
                }
                if (null != firstObj && null != secondObj)
                {
                    ConnectorViewModel con1 = new ConnectorViewModel(firstObj.RightConnector, secondObj.TopConnector);
                    con1.Parent = window1ViewModel.DiagramViewModel;
                    con1.Id     = maxId * firstObj.Id + secondObj.Id; //:)
                    window1ViewModel.DiagramViewModel.Items.Add(con1);
                }
            }
        }
Пример #3
0
        void AddNewLink(SimpleLink newLink)
        {
            SettingsDesignerItemViewModel firstObj  = null;
            SettingsDesignerItemViewModel secondObj = null;

            try
            {
                firstObj  = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(f => f.Id == newLink.Start);
                secondObj = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(s => s.Id == newLink.End);
            }
            catch (Exception)
            {
                return; //:)
            }
            if (null != firstObj && null != secondObj)
            {
                ConnectorViewModel con1 = new ConnectorViewModel(firstObj.RightConnector, secondObj.TopConnector);
                con1.Parent = window1ViewModel.DiagramViewModel;
                con1.Id     = newLink.Id;
                window1ViewModel.DiagramViewModel.Items.Add(con1);
            }
        }
Пример #4
0
        void DeleteOld(SimpleObject oldObj)
        {
            SettingsDesignerItemViewModel firstObj = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(f => f.Id == oldObj.Id);

            window1ViewModel.DiagramViewModel.Items.Remove(firstObj);
        }