示例#1
0
        public Session(UIElement parent, string name, ConstructorMods mod)
        {
            Name = name;
            if (mod == ConstructorMods.New)
            {
                tree = new TheoryTree();
            }
            else if (mod == ConstructorMods.Load)
            {
                try
                {
                    Microsoft.Win32.OpenFileDialog filedialog = new Microsoft.Win32.OpenFileDialog();
                    filedialog.InitialDirectory = SaveLoad.currentFoldierPath;
                    filedialog.DefaultExt = SaveLoad.fileExtension;
                    filedialog.ShowDialog();

                    object loadedObject = null;
                    SaveLoad.LoadData(filedialog.SafeFileName, out loadedObject);
                    tree = (TheoryTree)loadedObject;
                }
                catch (Exception e)
                {
                    exceptionHandler.Add(e);
                    tree = new TheoryTree();
                }
            }

            treeController = new TheoryTreeController(tree);
            elementspace = new ElementSpace(tree, treeController, this);
            visualRepresentation = new SessionVisual(elementspace,tree,this);

            if (parent is DockPanel)
            {
                DockPanel panel = (DockPanel)parent;
                panel.Children.Add(visualRepresentation);
            }
            elementspace = visualRepresentation.GetElementSpace();
        }
        //***************************Element Space***************************************************************************************************************************************************************************
        public ElementSpace(TheoryTree tree, TheoryTreeController treeController, Session session)
        {
            InitializeComponent();
            allocator = new ElementAllocator(Children,this);
            //arrows = new Arrows(this);
            this.session = session;
            this.tree = tree;
            this.treeController = treeController;
            this.tree.ContentUpdated += new Protsenko.TheoryEditor.Core.Events.ContentUpdated(tree_ContentUpdated);
            focusedObjects = new List<TheoryVisualDecorator>();

            this.MouseRightButtonUp += new MouseButtonEventHandler(CanvasMy_MouseRightButtonUp);
            this.MouseLeftButtonDown += new MouseButtonEventHandler(dragpanel_MouseLeftButtonDown);
            this.MouseMove += new MouseEventHandler(dragpanel_MouseMove);
            this.MouseLeftButtonUp += new MouseButtonEventHandler(dragpanel_MouseLeftButtonUp);
            this.MouseLeave += new MouseEventHandler(CanvasMy_MouseLeave);
            this.MouseWheel += new MouseWheelEventHandler(CanvasMy_MouseWheel);
            this.LayoutUpdated += new EventHandler(ElementSpace_LayoutUpdated);     // not mvc //костыль
            this.ElementsFocused += new Protsenko.TheoryEditor.Core.Events.Focused(ElementSpace_ElementFocused);

            if (tree.Count != 0)
                tree.RunUpdateForeachElement();
        }
        public void SetMC(TheoryTree tree, TheoryTreeController treeController)
        {
            this.tree = tree;
            this.treeController = treeController;
            this.tree.ContentUpdated += new Protsenko.TheoryEditor.Core.Events.ContentUpdated(tree_ContentUpdated);

            this.Children.Clear();

            if (tree.Count != 0)
                tree.RunUpdateForeachElement();
        }