Наследование: Caliburn.Micro.PropertyChangedBase
Пример #1
0
 public override void StartSettings()
 {
     var viewModel = new ShapeLayerColorPickerViewModel(this, _filePath);
     
     _element = FloatingHelpers.CreateFloatingElement("Color Picker", new Point(400, 400), new Size(400, 400), viewModel);
     AppStateSettings.Instance.FloatingItems.AddFloatingElement(_element);
 }
Пример #2
0
        private void TagVisualizationLoaded(object sender, RoutedEventArgs e)
        {

            {
                var c = State.Imb.Clients.Where((k => k.Value.TagID != "" && Convert.ToByte(int.Parse(k.Value.TagID, NumberStyles.HexNumber)) == VisualizedTag.Value)).FirstOrDefault();

                if (c.Value != null)
                {
                    Status = c.Value;
                    var fe = new FloatingElement
                    {
                        AllowDrop = true,
                        AllowedDropsTags = new List<string>() { "document" }
                    };
                    fe.Drop += fe_Drop;
                    fe.DragEnter += (s, es) => { Opacity = 0.5; };
                    fe.DragLeave += (s, es) => { Opacity = 1; };
                    border.DataContext = fe;
                    SurfaceDragDrop.AddDragEnterHandler(this, (s, ea) => this.Opacity = 0.5); // VisualStateManager.GoToState(this,"DragOver",true));
                    SurfaceDragDrop.AddDragLeaveHandler(this, (s, ea) => this.Opacity = 1.0); // VisualStateManager.GoToState(this, "Normal", true));
                    SurfaceDragDrop.AddDropHandler(this, (s, ea) => {
                        if (!(ea.Cursor.Data is Document)) return;
                        // send document
                        var d = (Document)ea.Cursor.Data;
                        this.Opacity = 1.0;
                        AppStateSettings.Instance.SendDocument(Status, d);
                    });
                }
                LostTag += UcSensiconLostTag;
            }

            Moved += UcSensiconMoved;
        }
Пример #3
0
        /// <summary>
        /// Tries to open a Floating element by looking in all referenced assemblies for the full namespace of the viewmodel
        /// </summary>
        /// <param name="modelName"></param>
        /// <param name="args"></param>
        /// <param name="title"></param>
        /// <param name="sizeX"></param>
        /// <param name="sizeY"></param>
        /// <param name="posX"></param>
        /// <param name="posY"></param>
        public object OpenWindow(string modelName, object[] args = null, string title = "Window", double sizeX = 600, double sizeY = 400, double posX = 500, double posY = 500, string id = "", bool border = true)
        {
            if (!IsActive()) return null;

            object viewModel = null;
            Type modelType = null;
            try
            {
                //var args2 = new object[] {1, 2, 4};
                try
                {
                    
                    var ea = Assembly.GetEntryAssembly();
                    modelType = ea.GetType(modelName);
                    if (modelType == null)
                    {
                        
                        foreach (var refassNm in AppDomain.CurrentDomain.GetAssemblies())
                        {
                            modelType = refassNm.GetType(modelName);
                            if (modelType != null)
                            {
                                break;
                            }
                        }
                    }
                    
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                Execute.OnUIThread(() =>
                {
                    try
                    {
                        if(modelType != null)
                            viewModel = Activator.CreateInstance(modelType, args);
                        if (viewModel != null)
                        {
                            var fe = new FloatingElement()
                            {
                                OpacityDragging = 0.5,
                                OpacityNormal = 1.0,
                                CanMove = true,
                                CanRotate = true,
                                CanScale = true,
                                StartOrientation = 0,
                                Width = sizeX,
                                Height = sizeY,
                                Background = Brushes.DarkOrange,
                                StartPosition = new Point(posX, posY),
                                MinSize = new Size(sizeX, sizeY),
                                ShowsActivationEffects = false,
                                RemoveOnEdge = true,
                                Contained = true,
                                Title = title,
                                Foreground = Brushes.White,
                                DockingStyle = DockingStyles.None,
                                ModelInstance = viewModel,
                            };
                            if (id != "") fe.Id = id;
                            if (!border) fe.Style = Application.Current.FindResource("NoBorder") as Style;
                            AppStateSettings.Instance.FloatingItems.Add(fe);
                            _ownFloatingElements.Add(fe);
                        }
                        //return viewModel;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                });
            }
            catch (Exception ex)
            {
                string exc = ex.Message;
            }
            return viewModel;
        }
Пример #4
0
        private static void AnimateOpacityWindow(FloatingElement fe, double posX, double posY, long duration = 2000)
        {

            // Animate opacity 
            if (fe != null && fe.ScatterViewItem != null)
            {
                var o = new System.Windows.Media.Animation.DoubleAnimation(posX, posY,
                                                                           TimeSpan.FromMilliseconds(duration));
                fe.ScatterViewItem.BeginAnimation(ScatterContentControlBase.OpacityProperty, o);
            }
            //pa.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseIn, Exponent = -3 };
        }
Пример #5
0
        private static void AnimateWindow(FloatingElement fe,double posX, double posY, long duration=2000)
        {
// Animate to

            var pa = new PointAnimation();
            pa.From = fe.ScatterViewItem.Center;
            pa.To = new Point(posX, posY);
            pa.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
            pa.EasingFunction = new ExponentialEase() {EasingMode = EasingMode.EaseIn, Exponent = -3};
            fe.ScatterViewItem.BeginAnimation(ScatterContentControlBase.CenterProperty, pa);
            
            //fe.ScatterViewItem.BeginAnimation(ScatterContentControlBase.CenterProperty, null);
            //fe.ScatterViewItem.
            //fe.ScatterViewItem.Center = new Point(posX, posY);
        }
Пример #6
0
 private void SettingsFloatingElementOnClosed(object sender, EventArgs eventArgs)
 {
     _settingsFloatingElement = null;
 }
Пример #7
0
        private void EditMenuItem_OnTap(object sender, RoutedEventArgs e)
        {
            Execute.OnUIThread(() =>
            {
                if (_settingsFloatingElement == null)
                {
                    _settingsFloatingElement = FloatingHelpers.CreateFloatingElement("Effects model settings",
                        new Point(350, 340), new Size(500, 550), _direction.SettingsViewModel);
                    _settingsFloatingElement.Closed += SettingsFloatingElementOnClosed;
                    AppState.FloatingItems.AddFloatingElement(_settingsFloatingElement);
                }

            });
        }
Пример #8
0
        private void RemoveMenuItem_OnTap(object sender, RoutedEventArgs e)
        {
            if (_settingsFloatingElement != null)
            {
                _settingsFloatingElement.Close();
            }
            
            _settingsFloatingElement = null;

            _direction.Remove();
        }
Пример #9
0
 private void RemoveFloatingElement() {
     floatingElement = AppState.FloatingItems.FirstOrDefault(f => string.Equals((string) f.Id, taskDragItem.FloatingElementId));
     if (floatingElement == null) return;
     AppState.FloatingItems.Remove(floatingElement);
 }
Пример #10
0
        private void UcPhotoContactTap(object sender, TouchEventArgs e)
        {
            if (Feature is PhotoFeature)
            {
                var pf = (PhotoFeature) Feature;
                var fe = new FloatingElement
                             {
                                 Document = new Document {FileType = FileTypes.image, Location = pf.ImageUrl},
                                 OpacityDragging = 0.5,
                                 OpacityNormal = 1.0,
                                 CanMove = true,
                                 CanRotate = true,
                                 CanScale = true,
                                 StartOrientation = e.Device.GetOrientation(Application.Current.MainWindow) + 90,
                                 Background = Brushes.DarkOrange,
                                 MaxSize = new Size(500, (500.0/pf.Width)*pf.Height),
                                 StartPosition = e.TouchDevice.GetTouchPoint(Application.Current.MainWindow).Position,
                                 StartSize = new Size(200, (200.0/pf.Width)*pf.Height),
                                 MinSize = new Size(100, (100.0/pf.Width)*pf.Height),
                                 ShowsActivationEffects = false,
                                 RemoveOnEdge = true,
                                 Contained = true,
                                 Title = pf.Name,
                                 Foreground = Brushes.White,
                                 DockingStyle = DockingStyles.None,
                             };
                AppStateSettings.Instance.FloatingItems.Add(fe);
                //State.AddFloatingElement(new CoFile() { Location = pf.ImageUrl, Id = pf.Id, Name = pf.Name }, (pf.Width/2), (pf.Height/2));
            }

        }
Пример #11
0
 public void ForceDrop(object data, FloatingElement fe)
 {
     if (Drop != null) Drop(this, new FloatingDragDropEventArgs {Data = data, Element = fe});
 }
Пример #12
0
        protected override void OnViewLoaded(object loadedView)
        {
            base.OnViewLoaded(loadedView);
            view = (SpiderView) loadedView;
            
            svi = Helpers.FindElementOfTypeUp(view, typeof (ScatterViewItem)) as ScatterViewItem;
            if (svi != null && svi.DataContext is FloatingElement) fe = (FloatingElement) svi.DataContext;
            if (fe != null)
            {
                AppState.FullScreenFloatingElementChanged += (e, s) => NotifyOfPropertyChange(() => Large);
                NotifyOfPropertyChange(() => Large);
            }
            //AppraisalTab = AppState.Container.GetExportedValue<IAppraisalTab>();
            //AppraisalTab.Plugin = Plugin;
            Plugin.SelectedAppraisals.CollectionChanged += SelectedAppraisalsCollectionChanged;
            Plugin.PropertyChanged += (e, s) =>
                                          {
                                              if (!s.PropertyName.Equals("SelectedAppraisal")) return;
                                              UpdateNextPrevious();
                                              UpdateSpider();
                                          };
            if (Plugin.SelectedAppraisals.Count > 0) Plugin.SelectedAppraisal = Plugin.SelectedAppraisals.First();

            UpdateSpider();
        }
Пример #13
0
        public void Init()
        {
            // get file location
            BFile = ConfigurationManager.AppSettings["Bookmark.File"];
            if (string.IsNullOrEmpty(BFile)) BFile = "bookmarks.txt";
            var fi = new FileInfo(BFile);
            if (fi.Directory == null) return;
            // check if directory exists
            if (!fi.Directory.Exists)
            {
                Directory.CreateDirectory(fi.Directory.FullName);
            }

            Screen = new PinViewModel();

            // load bookmarks
            Bookmarks = BookmarkList.Load(BFile);
            //var viewModel = IoC.GetAllInstances(typeof(IBookmark)).FirstOrDefault() as IBookmark;
            var viewModel = (BookmarkViewModel)IoC.GetInstance(typeof(IBookmark), "");
            
            //container.GetExportedValueOrDefault<IBookmark>();
            if (viewModel != null)
            {
                viewModel.BFile = BFile;
                Element = FloatingHelpers.CreateFloatingElement("Bookmarks", DockingStyles.Up, viewModel, Icon,Priority);
                Element.LastContainerPosition = new ContainerPosition()
                {
                    Center = new Point(500, 400),
                    Size = new Size(500, 500)

                };
                Element.SwitchWidth = 450;
                Element.DragScaleFactor = 40;
                UpdateVisibility();
            }
            AppState.ViewDef.VisibleChanged += ViewDefVisibleChanged;
        }
Пример #14
0
        public override void StartSettings()
        {
            var fe = new FloatingElement
            {
                OpacityDragging = 0.5,
                OpacityNormal = 1.0,
                CanMove = true,
                CanRotate = true,
                CanScale = true,
                StartOrientation = 0,
                Background = Brushes.DarkOrange,
                StartPosition = new Point(400,400),
                StartSize = new Size(400, 500),
                ShowsActivationEffects = false,
                RemoveOnEdge = true,
                Contained = true,
                Title = "Rain Radar Configuration",
                Foreground = Brushes.White,
                DockingStyle = DockingStyles.None,
                ModelInstance = new RainRadarConfigViewModel(this)
            };
            AppStateSettings.Instance.FloatingItems.Add(fe);

        }
Пример #15
0
        /// <summary>
        /// Tries to open a Floating element by looking in all referenced assemblies for the full namespace of the viewmodel
        /// </summary>
        /// <param name="modelName"></param>
        /// <param name="args"></param>
        /// <param name="title"></param>
        /// <param name="sizeX"></param>
        /// <param name="sizeY"></param>
        /// <param name="posX"></param>
        /// <param name="posY"></param>
        public object OpenImage(string source,  object[] args = null, string title = "Window", string filetype = "image",double sizeX = 600, double sizeY = 400, double posX = 500, double posY = 500, string id="", bool border=false, double opacity = 1)
        {
            if (!IsActive()) return null;

            var ftype = (FileTypes) Enum.Parse(typeof(FileTypes),filetype);

            object viewModel = null;
            
            try
            {               
                Execute.OnUIThread(() =>
                {
                    try
                    {
                        Document doc = new Document() { Location = source, FileType = ftype };
                            var fe = new FloatingElement()
                            {
                                OpacityDragging = 0.5,
                                OpacityNormal = 1.0,
                                CanMove = false,
                                CanRotate = false,
                                CanScale = false,
                                StartOrientation = 0,
                                Width = sizeX,
                                Height = sizeY,
                                Background = Brushes.DarkOrange,
                                StartPosition = new Point(posX, posY),
                                MinSize = new Size(sizeX, sizeY),
                                ShowsActivationEffects = false,
                                RemoveOnEdge = true,
                                Contained = true,
                                Title = title,
                                Document = doc,
                                Foreground = Brushes.White,
                                DockingStyle = DockingStyles.None       ,
                                
                                
                            };
                            if (!border) fe.Style = Application.Current.FindResource("NoBorder") as Style;
                            if (id != "") fe.Id = id;
                            fe.OpacityNormal = opacity;
                            AppStateSettings.Instance.FloatingItems.Add(fe);
                            _ownFloatingElements.Add(fe);
                                                //return viewModel;
                    }
                    catch (Exception)
                    {

                    }
                });
            }
            catch (Exception ex)
            {
                string exc = ex.Message;
            }
            return viewModel;
        }
Пример #16
0
        private void AppStateDrop(object sender, DropEventArgs e) {
            if (!IsRunning || !(e.EventArgs.Cursor.Data is Appraisal)) return;
            //var a = (Appraisal) e.EventArgs.Cursor.Data;
            var avm = AppState.Container.GetExportedValue<IAppraisal>();

            avm.Plugin = this;
            var fe = new FloatingElement {
                ModelInstance = avm,
                OpacityDragging = 0.5,
                OpacityNormal = 1.0,
                CanDrag = true,
                CanMove = true,
                CanRotate = true,
                CanScale = true,
                Background = Brushes.DarkOrange,
                //MaxSize = new Size(500, (500.0 / pf.Width) * pf.Height),                                 
                StartPosition = e.Pos,
                StartSize = new Size(200, 200),
                Width = 300,
                Height = 300,
                ShowsActivationEffects = false,
                RemoveOnEdge = true,
                Contained = true,
                CanFullScreen = true,
                Title = "Appraisal",
                Foreground = Brushes.White,
                DockingStyle = DockingStyles.None,
            };
            AppState.FloatingItems.Add(fe);
        }
Пример #17
0
 public void Stop() {
     ShowConfirmation = false;
     foreach (var border in visitedBorders)
         border.Background = Brushes.Yellow;
     visitedBorders.Clear();
     AppState.RestoreVisibleState();
     floatingElement = null;
     Plugin.ActiveTask = null;
 }