예제 #1
0
        public void InitDiagram(DiagramVM diagram)
        {
            _mDiagram  = diagram;
            SnapToGrid = (_mDiagram.SnapSettings.SnapConstraints &
                          SnapConstraints.SnapToLines) == SnapConstraints.SnapToLines;

            SnapToObject = _mDiagram.SnapSettings.SnapToObject == Syncfusion.UI.Xaml.Diagram.SnapToObject.All;
            OnPropertyChanged(PageConstants.SelectedFormat);
        }
예제 #2
0
        /// <summary>
        /// Represents the log data.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        public void LogData(object data)
        {
            DiagramVM info = (Application.Current.MainWindow.DataContext as DiagramBuilderVM).SelectedDiagram;

            if (info != null)
            {
                info.HistoryManager.LogData(this, data);
            }
        }
예제 #3
0
        public async void LoadDiagram()
        {
            try
            {
                installedLocation = await installedLocation.CreateFolderAsync("DiagramBuilder", CreationCollisionOption.OpenIfExists);

                StorageFile indexFile             = null;
                IReadOnlyList <StorageFile> files = await installedLocation.GetFilesAsync();

                indexFile = files.Where(f => f.Name == "index.xml").FirstOrDefault();
                if (indexFile != null)
                {
                    XmlSerializer   deSerializer = new XmlSerializer(typeof(List <FileInfo>), new Type[] { typeof(FileInfo) });
                    List <FileInfo> fileIndex    = null;
                    using (Stream stream = await indexFile.OpenStreamForReadAsync())
                    {
                        fileIndex = deSerializer.Deserialize(stream) as List <FileInfo>;
                    }

                    foreach (FileInfo fileInfo in fileIndex.OrderBy(e => e.Index))
                    {
                        if (!files.Any(f => f.Name == fileInfo.FileName))
                        {
                            continue;
                        }
                        StorageFile file = await installedLocation.GetFileAsync(fileInfo.FileName);

                        DiagramVM newdiagram = GetNewDiagramVM(file, true);
                        newdiagram.IsSelected = fileInfo.Selected;
                        newdiagram.Title      = fileInfo.Title;
                        Diagrams.Add(newdiagram);

                        //FileItem item = new FileItem();
                        //item.Name = file.DisplayName;
                        //item.Load = this.Load;
                        //BasicProperties properties = await file.GetBasicPropertiesAsync();
                        //item.LastUpdated = properties.DateModified;
                        //items.Add(item);
                    }
                }
            }
            catch
            {
            }
            if (Diagrams.Count == 0)
            {
                OnNewCommand(null);
            }
            //else
            //{
            //    SelectedDiagram = Diagrams[0];
            //}
        }
예제 #4
0
        public async void OnNewCommand(object param)
        {
            StorageFile s         = null;
            string      parameter = Guid.NewGuid().ToString("N");

            //if (EnsureUnsnapped())
            {
                s = await installedLocation.CreateFileAsync(parameter + ".xml", CreationCollisionOption.FailIfExists);
            }
            if (s != null)
            {
                DiagramVM newDiagram = GetNewDiagramVM(s, false);
                Diagrams.Add(newDiagram);
                SelectedDiagram = newDiagram;
            }
            await SaveFileIndex();
        }
예제 #5
0
        /// <summary>
        /// Represents the log data.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        public void LogData(object data)
        {
            DiagramVM info = null;

            foreach (Window win in Application.Current.Windows)
            {
                if (win.DataContext is DiagramBuilderVM)
                {
                    info = (win.DataContext as DiagramBuilderVM).SelectedDiagram;
                }
            }

            if (info != null)
            {
                info.HistoryManager.LogData(this, data);
            }
        }
예제 #6
0
        /// <summary>
        /// The on property changed.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        protected override void OnPropertyChanged(string name)
        {
            base.OnPropertyChanged(name);

            DiagramVM info = null;

            foreach (Window win in Application.Current.Windows)
            {
                if (win.DataContext is DiagramBuilderVM)
                {
                    info = (win.DataContext as DiagramBuilderVM).SelectedDiagram;
                }
            }

            if (info != null && info.HistoryManager != null && this.AllowToLogData(name))
            {
                if (info.HistoryManager.CanLogData(info.HistoryManager, this._mCollectionData))
                {
                    this.LogData(this._mCollectionData);
                }
            }

            switch (name)
            {
            case GroupableConstants.FontSize:
            case GroupableConstants.Font:
            case GroupableConstants.FontStyle:
            case GroupableConstants.FontWeight:
            case GroupableConstants.TextAlignment:
            case GroupableConstants.LabelBackground:
            case GroupableConstants.LabelForeground:
            case GroupableConstants.Decoration:
            case "RotateAngle":
                this._mCollectionData.LabelForeground = this.LabelForeground;
                this._mCollectionData.Font            = this.Font;
                this._mCollectionData.FontSize        = this.FontSize;
                this._mCollectionData.FontStyle       = this.FontStyle;
                this._mCollectionData.FontWeight      = this.FontWeight;
                this._mCollectionData.LabelBackground = this.LabelBackground;
                this._mCollectionData.TextAlignment   = this.TextAlignment;
                this._mCollectionData.RotateAngle     = this.RotateAngle;
                this._mCollectionData.Decoration      = this.Decoration;
                break;
            }
        }
예제 #7
0
        private DiagramVM GetNewDiagramVM(StorageFile file, bool isValidXml)
        {
            DiagramVM diagram = new DiagramVM(file, isValidXml)
            {
                Title = "Untitled"
            };

            diagram.PortVisibility   = PortVisibility.Collapse;
            diagram.Delete           = Delete;
            diagram.PropertyChanged += (s, e) =>
            {
                DiagramVM sender = s as DiagramVM;
                if (e.PropertyName == "IsSelected")
                {
                    if (sender.IsSelected == true)
                    {
                        this.SelectedDiagram = sender;
                    }
                }
            };
            return(diagram);
        }
예제 #8
0
        public async void OnDeleteCommand(object param)
        {
            DiagramVM diag  = param as DiagramVM;
            int       index = Diagrams.IndexOf(diag);

            Diagrams.Remove(diag);
            if (diag.IsSelected && Diagrams.Count > 0)
            {
                if (Diagrams.Count == index)
                {
                    Diagrams[index - 1].IsSelected = true;
                }
                else if (Diagrams.Count > index)
                {
                    Diagrams[index].IsSelected = true;
                }
            }
            await SaveFileIndex();

            if (Diagrams.Count == 0)
            {
                Exit.Execute(null);
            }
        }