Exemplo n.º 1
0
        public string Format(IModelingDesignerComponent component)
        {
            var block = component as BlockControl;
            var title = block.TypeName;

            //在设计器中检测,如果有命名冲突,则显示全类型名。
            var designer = ModelingDesigner.GetDesigner(component as DependencyObject);

            if (designer != null)
            {
                if (designer.Blocks.Any(a => a != block && a.TypeName == title))
                {
                    title = block.TypeFullName;
                }
            }

            //如果有 label,则附加显示 Label。
            var label = block.Label;

            if (!string.IsNullOrWhiteSpace(label))
            {
                title += "(" + label + ")";
            }

            return(title);
        }
Exemplo n.º 2
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     var file = ModelingDesignerExtension.GetCurrentOdmlFile(designer);
     if (file != null)
     {
         designer.LoadDocument(file);
     }
 }
Exemplo n.º 3
0
        internal void ResetTitle()
        {
            var designer = ModelingDesigner.GetDesigner(this);

            if (designer != null)
            {
                this.Title = designer.BlockTitleFormatter.Format(this);
            }
        }
Exemplo n.º 4
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     var dialog = new OpenFileDialog { Filter = "Rafy Domain Mackup File (*.odml)|*.odml" };
     var res = dialog.ShowDialog();
     if (res == true)
     {
         designer.LoadDocument(dialog.FileName);
     }
 }
Exemplo n.º 5
0
        private void AddConnectionIntoCanvas(BlockRelation relation)
        {
            var con = relation.CreateConnection();

            ModelingDesigner.SetComponent(con, relation);

            //从 0 开始添加,可以保证连接显示在元素之后。
            _canvas.Children.Insert(0, con);
        }
Exemplo n.º 6
0
 internal static void BindDocument(ModelingDesigner designer, ODMLDocument document)
 {
     var binder = new DocumentBinder
     {
         _designer = designer,
         _document = document
     };
     binder.BindDocument();
 }
Exemplo n.º 7
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     foreach (var item in designer.SelectedItems)
     {
         if (item.Kind == DesignerComponentKind.Relation)
         {
             var relation = item as BlockRelation;
             relation.Hidden = !relation.Hidden;
         }
     }
 }
Exemplo n.º 8
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     var selectedItems = designer.SelectedItems.ToArray();
     foreach (var item in selectedItems)
     {
         if (item.Kind == DesignerComponentKind.Block)
         {
             designer.Blocks.Remove(item as BlockControl);
         }
     }
 }
Exemplo n.º 9
0
        internal static CommandBinding CreateCommandBinding(ModelingDesigner designer, WPFDesignerCommand cmd)
        {
            var adpater = new WPFCommandAdapter(cmd, designer);

            var wpfCmd = cmd.GetWPFCommand();

            var binding = new CommandBinding(wpfCmd);
            binding.Executed += adpater.binding_Executed;
            binding.CanExecute += adpater.binding_CanExecute;

            return binding;
        }
Exemplo n.º 10
0
        protected override void ExecuteCore(ModelingDesigner designer)
        {
            var file = ModelingDesignerExtension.GetCurrentOdmlFile(designer);
            if (file == null)
            {
                var dialog = new SaveFileDialog { Filter = "Rafy Domain Mackup File (*.odml)|*.odml" };
                var res = dialog.ShowDialog();
                if (res != true) return;

                file = dialog.FileName;
            }

            designer.SaveDocument(file);
        }
Exemplo n.º 11
0
        protected override void ExecuteCore(ModelingDesigner designer)
        {
            var selectedItems = designer.SelectedItems.ToArray();
            foreach (var item in selectedItems)
            {
                if (item.Kind == DesignerComponentKind.Block)
                {
                    designer.Blocks.Remove(item as BlockControl);
                }
            }

            //先删除所有的块后,如果还剩下选择的连接没有移除的话,说明用户想删除某个连接对应的关系,这时需要进行提示。
            selectedItems = designer.SelectedItems.ToArray();
            if (selectedItems.All(c => c.Kind == DesignerComponentKind.Relation))
            {
                var res = MessageBox.Show("确定删除关系?", "确认删除", MessageBoxButton.YesNo);
                if (res != MessageBoxResult.Yes) return;
            }

            foreach (var item in selectedItems)
            {
                designer.Relations.Remove(item as BlockRelation);
            }
        }
Exemplo n.º 12
0
 internal WPFCommandAdapter(WPFDesignerCommand cmd, ModelingDesigner designer)
 {
     _cmd = cmd;
     _designer = designer;
 }
Exemplo n.º 13
0
 /// <summary>
 /// 检查设计器状态,返回当前是否可执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 /// <returns></returns>
 protected virtual bool CanExecuteCore(ModelingDesigner designer)
 {
     return true;
 }
Exemplo n.º 14
0
 /// <summary>
 /// 执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 protected abstract void ExecuteCore(ModelingDesigner designer);
Exemplo n.º 15
0
 /// <summary>
 /// 检查设计器状态,返回当前是否可执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 /// <returns></returns>
 public bool CanExecute(ModelingDesigner designer)
 {
     return this.CanExecuteCore(designer);
 }
Exemplo n.º 16
0
 /// <summary>
 /// 执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 public void Execute(ModelingDesigner designer)
 {
     this.ExecuteCore(designer);
 }
Exemplo n.º 17
0
 internal static string GetCurrentOdmlFile(ModelingDesigner element)
 {
     return (string)element.GetValue(CurrentOdmlFileProperty);
 }
Exemplo n.º 18
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     designer.SelectAll();
 }
Exemplo n.º 19
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     designer.ShowHiddenRelations = !designer.ShowHiddenRelations;
 }
Exemplo n.º 20
0
 private static void SetCurrentOdmlFile(ModelingDesigner element, string value)
 {
     element.SetValue(CurrentOdmlFileProperty, value);
 }
Exemplo n.º 21
0
 public EditorProperties(EditorPane editor)
 {
     _editor = editor;
     _designer = editor.Designer;
 }
Exemplo n.º 22
0
 private static bool GetIsReBinding(ModelingDesigner element)
 {
     return (bool)element.GetValue(IsReBindingProperty);
 }
Exemplo n.º 23
0
 private static void SetIsReBinding(ModelingDesigner element, bool value)
 {
     element.SetValue(IsReBindingProperty, value);
 }