Example #1
0
        /// <summary>
        /// 加载所有的便签窗口到数据表中
        /// </summary>
        private void LoadAllNoteView()
        {
            List <DataModel> listViewData = new List <DataModel>();

            foreach (System.Windows.Window noteView in Application.Current.Windows)
            {
                if (noteView.GetType() != typeof(StickyNoteView))
                {
                    continue;
                }
                StickyNoteView view = noteView as StickyNoteView;
                //Data litm = new ListViewItem(view.Title);
                DataModel dataModel = new DataModel();
                //dataModel.id = view.ViewId;
                dataModel.title          = view.StickyNoteTitle.Content.ToString();
                dataModel.StickyNoteView = view;

                if (view.IsVisible)
                {
                    dataModel.isVisible = "显示";
                }
                else
                {
                    dataModel.isVisible = "隐藏";
                }


                listViewData.Add(dataModel);
            }
            dataGrid.ItemsSource = listViewData;
        }
Example #2
0
        public ViewSettingData(StickyNoteView stickyNoteView)
        {
            WinLeft = stickyNoteView.Left;
            WinTop  = stickyNoteView.Top;

            WinWidth  = stickyNoteView.Width;
            WinHeigth = stickyNoteView.Height;

            //******放弃使用富文本,原因在于富文本回车会假象换两行,再次读取内容时正常!且读取注册表内容数据后赋值控件后,末尾多加\r\n字符,
            //TextRange textRange = new TextRange(stickyNoteView.ContentTextBox.Document.ContentStart, stickyNoteView.ContentTextBox.Document.ContentEnd);
            //Data = textRange.Text;
            Data = stickyNoteView.ContentTextBox.Text;

            Theme = stickyNoteView.CurrentTheme;
            Style = stickyNoteView.CurrentStyle;

            Opacity = double.Parse(stickyNoteView.backgroundOpacity);
            Hidden  = !stickyNoteView.IsVisible;/////////由于获取IsVisible是获取窗口是否处于显示状态,是则为true,否则为false,而Hidden是关于隐藏的描述,如果隐藏则为true,否则为false ,所以需要取非

            Title       = stickyNoteView.StickyNoteTitle.Content.ToString();
            Topmost     = stickyNoteView.Topmost;
            CustomTheme = stickyNoteView.CustomTheme;
            //creationTime = stickyNoteView.CreationTime;
            CustomStyle = stickyNoteView.CustomStyle;
        }
Example #3
0
        /// <summary>
        /// 处理显示或隐藏方法
        /// </summary>
        /// <param name="status">传入隐藏或者显示</param>
        private void ProcessShowOrHidden(string status)
        {
            if (this.dataGrid.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选中某项再执行操作!", "提示"); return;
            }                                              //判断是否有选中项,否则提示退出
            var selectItems = this.dataGrid.SelectedItems; //获取选中的所有Item

            foreach (var item in selectItems)
            {
                DataModel      dataModel = item as DataModel;        //转换对象
                StickyNoteView noteView  = dataModel.StickyNoteView; //获取窗口,进行操作
                switch (status)
                {
                case "show":
                    noteView.Show();
                    break;

                case "hidden":
                    noteView.Hide();
                    break;

                default:
                    break;
                }

                noteView.Save();
            }
            LoadAllNoteView();//重新加载标签数据
        }
Example #4
0
 private SettingView(StickyNoteView stickyNote) : this()
 {
     stickyNoteView = stickyNote;//赋值全局变量
     LoadTheme();
     LoadStyle();
     LoadCurrentViewSetting();
 }
Example #5
0
 /// <summary>
 /// 单例创建
 /// </summary>
 /// <param name="stickyNote">传入便签窗口</param>
 /// <returns>返回创建的设置窗口</returns>
 public static SettingView GetInstance(StickyNoteView stickyNote)
 {
     if (SettingViewSingleton == null)         //双重锁定只需要一句判断就可以了
     {
         lock (locker)                         //线程锁
         {
             if (SettingViewSingleton == null) //判断类是否已经实例化
             {
                 SettingViewSingleton = new SettingView(stickyNote);
             }
         }
     }
     return(SettingViewSingleton);
 }
Example #6
0
 /// <summary>
 /// 赋值所有便签窗口天气信息
 /// </summary>
 /// <param name="weatherInfo">天气信息字符串</param>
 private static void AssignmentWeatherControl(string weatherInfo)
 {
     foreach (System.Windows.Window window in Application.Current.Windows)//遍历全部已创建的标签
     {
         if (window.GetType() != typeof(StickyNoteView))
         {
             continue;                                            //判断标签类型,是否一致,否则结束当前循环
         }
         StickyNoteView noteView = window as StickyNoteView;
         noteView.Dispatcher.BeginInvoke(new Action(() =>
         {
             noteView.contentWeather = weatherInfo;
         }));
     }
 }
Example #7
0
        /// <summary>
        /// 重置按钮便签位置
        /// </summary>
        private void Btn_Reset_OnClick(object sender, RoutedEventArgs e)
        {
            double screenWidth  = SystemParameters.PrimaryScreenWidth;  //得到屏幕整体宽度
            double screenHeight = SystemParameters.PrimaryScreenHeight; //得到屏幕整体高度

            foreach (System.Windows.Window noteView in Application.Current.Windows)
            {
                Random ran      = new Random(GetRandomSeed());
                int    minValue = 100;
                if (noteView.GetType() != typeof(StickyNoteView))
                {
                    continue;
                }
                StickyNoteView view = noteView as StickyNoteView;
                view.Top  = ran.Next(minValue, (int)screenHeight - minValue);
                view.Left = ran.Next(minValue, (int)screenWidth - minValue);
            }
        }
Example #8
0
        /// <summary>
        /// 删除选中项事件
        /// </summary>
        private void DeleteSelectNoteBtn_Click(object sender, RoutedEventArgs e)
        {
            if (this.dataGrid.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选中某项再执行操作!", "提示"); return;
            }
            ;                                                                                             //判断是否有选中项,否则退出
            if (MessageBox.Show("你确定要删除选中的便签?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;                                    //弹出提示,如果确定则删除,否则退出
            }
            var selectItems = this.dataGrid.SelectedItems; //获取选中的所有Item

            foreach (var item in selectItems)
            {
                DataModel      dataModel = item as DataModel;        //转换对象
                StickyNoteView noteView  = dataModel.StickyNoteView; //获取窗口,进行操作
                REGISTRY.Delete(noteView.ViewId.ToString());
                Window.EmptySlots.Enqueue(noteView.ViewId);          //去除集合中的项
                noteView.Close();
            }
            LoadAllNoteView();//重新加载标签数据
        }
Example #9
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.stickyNoteViewProp = ((MMY.StickyNote.UI.StickyNoteView)(target));
                return;

            case 2:
                this.NavBar = ((System.Windows.Controls.DockPanel)(target));

            #line 24 "..\..\..\View\StickyNoteView.xaml"
                this.NavBar.MouseMove += new System.Windows.Input.MouseEventHandler(this.StickyNote_MouseMove);

            #line default
            #line hidden
                return;

            case 3:
                this.AddStickyNote = ((System.Windows.Controls.Button)(target));
                return;

            case 4:
                this.TitleGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 5:
                this.StickyNoteTitle = ((System.Windows.Controls.Label)(target));

            #line 30 "..\..\..\View\StickyNoteView.xaml"
                this.StickyNoteTitle.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(this.StickyNoteTitle_MouseDoubleClick);

            #line default
            #line hidden
                return;

            case 6:
                this.editTitle = ((System.Windows.Controls.TextBox)(target));

            #line 31 "..\..\..\View\StickyNoteView.xaml"
                this.editTitle.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.EditTitle_OnPreviewKeyDown);

            #line default
            #line hidden
                return;

            case 7:
                this.HideAndClosePanel = ((System.Windows.Controls.DockPanel)(target));
                return;

            case 8:
                this.EditCompleted = ((System.Windows.Controls.Button)(target));
                return;

            case 9:
                this.HideStickyNote = ((System.Windows.Controls.Button)(target));
                return;

            case 10:
                this.Setting = ((System.Windows.Controls.Button)(target));
                return;

            case 11:
                this.WeatherShow = ((System.Windows.Controls.Label)(target));
                return;

            case 12:
                this.ContentTextBox = ((System.Windows.Controls.TextBox)(target));
                return;
            }
            this._contentLoaded = true;
        }