Example #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);
        }
Example #2
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     var file = ModelingDesignerExtension.GetCurrentOdmlFile(designer);
     if (file != null)
     {
         designer.LoadDocument(file);
     }
 }
Example #3
0
        internal void ResetTitle()
        {
            var designer = ModelingDesigner.GetDesigner(this);

            if (designer != null)
            {
                this.Title = designer.BlockTitleFormatter.Format(this);
            }
        }
Example #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);
     }
 }
Example #5
0
        private void AddConnectionIntoCanvas(BlockRelation relation)
        {
            var con = relation.CreateConnection();

            ModelingDesigner.SetComponent(con, relation);

            //从 0 开始添加,可以保证连接显示在元素之后。
            _canvas.Children.Insert(0, con);
        }
Example #6
0
 internal static void BindDocument(ModelingDesigner designer, ODMLDocument document)
 {
     var binder = new DocumentBinder
     {
         _designer = designer,
         _document = document
     };
     binder.BindDocument();
 }
Example #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;
         }
     }
 }
Example #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);
         }
     }
 }
Example #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;
        }
Example #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);
        }
Example #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);
            }
        }
Example #12
0
 internal WPFCommandAdapter(WPFDesignerCommand cmd, ModelingDesigner designer)
 {
     _cmd = cmd;
     _designer = designer;
 }
Example #13
0
 /// <summary>
 /// 检查设计器状态,返回当前是否可执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 /// <returns></returns>
 protected virtual bool CanExecuteCore(ModelingDesigner designer)
 {
     return true;
 }
Example #14
0
 /// <summary>
 /// 执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 protected abstract void ExecuteCore(ModelingDesigner designer);
Example #15
0
 /// <summary>
 /// 检查设计器状态,返回当前是否可执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 /// <returns></returns>
 public bool CanExecute(ModelingDesigner designer)
 {
     return this.CanExecuteCore(designer);
 }
Example #16
0
 /// <summary>
 /// 执行本命令。
 /// </summary>
 /// <param name="designer"></param>
 public void Execute(ModelingDesigner designer)
 {
     this.ExecuteCore(designer);
 }
 internal static string GetCurrentOdmlFile(ModelingDesigner element)
 {
     return (string)element.GetValue(CurrentOdmlFileProperty);
 }
Example #18
0
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     designer.SelectAll();
 }
 protected override void ExecuteCore(ModelingDesigner designer)
 {
     designer.ShowHiddenRelations = !designer.ShowHiddenRelations;
 }
 private static void SetCurrentOdmlFile(ModelingDesigner element, string value)
 {
     element.SetValue(CurrentOdmlFileProperty, value);
 }
Example #21
0
 public EditorProperties(EditorPane editor)
 {
     _editor = editor;
     _designer = editor.Designer;
 }
Example #22
0
 private static bool GetIsReBinding(ModelingDesigner element)
 {
     return (bool)element.GetValue(IsReBindingProperty);
 }
Example #23
0
 private static void SetIsReBinding(ModelingDesigner element, bool value)
 {
     element.SetValue(IsReBindingProperty, value);
 }